summaryrefslogtreecommitdiffstats
path: root/generic/tclFCmd.c
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley@noemail.net>2005-06-09 16:24:41 (GMT)
committervincentdarley <vincentdarley@noemail.net>2005-06-09 16:24:41 (GMT)
commitf7da6f394c3652ffb20e9701fe1a4927d93e34ad (patch)
tree24b3c804b6d6234507385245a05ad20d5d75fb03 /generic/tclFCmd.c
parentfebaa4bb60ff8e238b6ca95ce5f84fa1aeee237b (diff)
downloadtcl-f7da6f394c3652ffb20e9701fe1a4927d93e34ad.zip
tcl-f7da6f394c3652ffb20e9701fe1a4927d93e34ad.tar.gz
tcl-f7da6f394c3652ffb20e9701fe1a4927d93e34ad.tar.bz2
fix to race condition in file mkdir and fix to glob documentation
FossilOrigin-Name: a6ebffa26e5ce24b5fe04090cc847756b4bdeb62
Diffstat (limited to 'generic/tclFCmd.c')
-rw-r--r--generic/tclFCmd.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c
index f8606e5..9ee530b 100644
--- a/generic/tclFCmd.c
+++ b/generic/tclFCmd.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclFCmd.c,v 1.32 2005/05/10 18:34:37 kennykb Exp $
+ * RCS: @(#) $Id: tclFCmd.c,v 1.33 2005/06/09 16:24:47 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -261,11 +261,35 @@ TclFileMakeDirsCmd(interp, objc, objv)
errfile = target;
goto done;
}
- } else if ((errno != ENOENT)
- || (Tcl_FSCreateDirectory(target) != TCL_OK)) {
+ } else if (errno != ENOENT) {
errfile = target;
goto done;
}
+
+ if (Tcl_FSCreateDirectory(target) != TCL_OK) {
+ /*
+ * Create might have failed because of being in a race
+ * condition with another process trying to create the
+ * same subdirectory.
+ */
+ if (errno == EEXIST) {
+ 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;
+ }
+ } else {
+ errfile = target;
+ goto done;
+ }
+ }
+
/* Forget about this sub-path */
Tcl_DecrRefCount(target);
target = NULL;