summaryrefslogtreecommitdiffstats
path: root/generic/tclFCmd.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-10-17 19:47:01 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-10-17 19:47:01 (GMT)
commit1b03667a27e4f198e48c344454663aae4c085a14 (patch)
tree70bbdddb4f6bdec0c26dd22cf8ccd499b1c97416 /generic/tclFCmd.c
parent5c24bebd2b402df644549d6c0efe6586dde65891 (diff)
parente154c5151281fbbe01ef1361f5f6980a5ec5a6d3 (diff)
downloadtcl-1b03667a27e4f198e48c344454663aae4c085a14.zip
tcl-1b03667a27e4f198e48c344454663aae4c085a14.tar.gz
tcl-1b03667a27e4f198e48c344454663aae4c085a14.tar.bz2
merge 8.7
Diffstat (limited to 'generic/tclFCmd.c')
-rw-r--r--generic/tclFCmd.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c
index ddfe3bf..ea2a1c5 100644
--- a/generic/tclFCmd.c
+++ b/generic/tclFCmd.c
@@ -240,9 +240,13 @@ TclFileMakeDirsCmd(
break;
}
for (j = 0; j < pobjc; j++) {
+ int errCount = 2;
+
target = Tcl_FSJoinPath(split, j + 1);
Tcl_IncrRefCount(target);
+ createDir:
+
/*
* Call Tcl_FSStat() so that if target is a symlink that points to
* a directory we will create subdirectories in that directory.
@@ -269,23 +273,25 @@ TclFileMakeDirsCmd(
* subdirectory.
*/
- if (errno != EEXIST) {
- errfile = target;
- goto done;
- } else if ((Tcl_FSStat(target, &statBuf) == 0)
- && S_ISDIR(statBuf.st_mode)) {
- /*
- * It is a directory that wasn't there before, so keep
- * going without error.
- */
-
- Tcl_ResetResult(interp);
- } else {
- errfile = target;
- goto done;
+ if (errno == EEXIST) {
+ /* Be aware other workers could delete it immediately after
+ * creation, so give this worker still one chance (repeat once),
+ * see [270f78ca95] for description of the race-condition.
+ * Don't repeat the create always (to avoid endless loop). */
+ if (--errCount > 0) {
+ goto createDir;
+ }
+ /* Already tried, with delete in-between directly after
+ * creation, so just continue (assume created successful). */
+ goto nextPart;
}
+
+ /* return with error */
+ errfile = target;
+ goto done;
}
+ nextPart:
/*
* Forget about this sub-path.
*/