summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2005-06-09 16:24:42 (GMT)
committervincentdarley <vincentdarley>2005-06-09 16:24:42 (GMT)
commit7265e63b582f1b5437c6819f29c4a72531aa3d6a (patch)
tree24b3c804b6d6234507385245a05ad20d5d75fb03 /generic
parent4afb8f350cf1359f2e21518ab8b6dd3694540fa5 (diff)
downloadtcl-7265e63b582f1b5437c6819f29c4a72531aa3d6a.zip
tcl-7265e63b582f1b5437c6819f29c4a72531aa3d6a.tar.gz
tcl-7265e63b582f1b5437c6819f29c4a72531aa3d6a.tar.bz2
fix to race condition in file mkdir and fix to glob documentation
Diffstat (limited to 'generic')
-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;