diff options
author | sebres <sebres@users.sourceforge.net> | 2018-07-09 19:03:38 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2018-07-09 19:03:38 (GMT) |
commit | a76637248c5d765f3e2ccc318193546b65ecaefd (patch) | |
tree | bed35f0e8982b83356dea726198571df8a0ded1e | |
parent | 64cbe6e187a319a8a9cef0d6201f22ba68a7ed60 (diff) | |
parent | 2a46a486706d9b30fc3eb90f975317bfdd3a9e40 (diff) | |
download | tcl-a76637248c5d765f3e2ccc318193546b65ecaefd.zip tcl-a76637248c5d765f3e2ccc318193546b65ecaefd.tar.gz tcl-a76637248c5d765f3e2ccc318193546b65ecaefd.tar.bz2 |
merge 8.6
-rw-r--r-- | generic/tclFCmd.c | 34 |
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. */ |