diff options
author | vincentdarley <vincentdarley> | 2005-06-09 16:24:42 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley> | 2005-06-09 16:24:42 (GMT) |
commit | 7265e63b582f1b5437c6819f29c4a72531aa3d6a (patch) | |
tree | 24b3c804b6d6234507385245a05ad20d5d75fb03 | |
parent | 4afb8f350cf1359f2e21518ab8b6dd3694540fa5 (diff) | |
download | tcl-7265e63b582f1b5437c6819f29c4a72531aa3d6a.zip tcl-7265e63b582f1b5437c6819f29c4a72531aa3d6a.tar.gz tcl-7265e63b582f1b5437c6819f29c4a72531aa3d6a.tar.bz2 |
fix to race condition in file mkdir and fix to glob documentation
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | doc/glob.n | 11 | ||||
-rw-r--r-- | generic/tclFCmd.c | 30 |
3 files changed, 36 insertions, 10 deletions
@@ -1,3 +1,8 @@ +2005-06-09 Vince Darley <vincentdarley@users.sourceforge.net> + + * generic/tclFCmd.c: fix to race condition in file mkdir [Bug 1217375] + * doc/glob.n: improve glob documentation [Bug 1190891] + 2005-06-09 Donal K. Fellows <dkf@users.sf.net> * doc/expr.n, doc/mathfunc.n: Fix minor typos [Bug 1211078] and @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: glob.n,v 1.17 2004/10/27 12:53:22 dkf Exp $ +'\" RCS: @(#) $Id: glob.n,v 1.18 2005/06/09 16:24:47 vincentdarley Exp $ '\" .so man.macros .TH glob n 8.3 Tcl "Tcl Built-In Commands" @@ -21,7 +21,9 @@ glob \- Return names of files that match patterns .PP This command performs file name ``globbing'' in a fashion similar to the csh shell. It returns a list of the files whose names match any -of the \fIpattern\fR arguments. +of the \fIpattern\fR arguments. No particular order is guaranteed +in the list, so if a sorted list is required the caller should use +\fBlsort\fR. .LP If the initial arguments to \fBglob\fR start with \fB\-\fR then they are treated as switches. The following switches are @@ -157,11 +159,6 @@ be used with \fBfile join\fR, to avoid them being interpreted as absolute paths pointing to a given user's home directory. .SH "PORTABILITY ISSUES" .PP -Unlike other Tcl commands that will accept both network and native -style names (see the \fBfilename\fR manual entry for details on how -native and network names are specified), the \fBglob\fR command only -accepts native names. -.TP \fBWindows\fR . For Windows UNC names, the servername and sharename components of the path 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; |