diff options
author | sebres <sebres@users.sourceforge.net> | 2018-07-09 18:15:34 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2018-07-09 18:15:34 (GMT) |
commit | 2a46a486706d9b30fc3eb90f975317bfdd3a9e40 (patch) | |
tree | 8d9e5b67823c769475e524e1376cd4b3b1ab5c29 /generic/tclFCmd.c | |
parent | 367ce9ad482394057c4d895abb67ffe50f1ac015 (diff) | |
parent | 51aecf205dab16072098f2f5119d6b9026f73e65 (diff) | |
download | tcl-2a46a486706d9b30fc3eb90f975317bfdd3a9e40.zip tcl-2a46a486706d9b30fc3eb90f975317bfdd3a9e40.tar.gz tcl-2a46a486706d9b30fc3eb90f975317bfdd3a9e40.tar.bz2 |
merge 8.5
Diffstat (limited to 'generic/tclFCmd.c')
-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 0f0f5da..fda2940 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. */ |