diff options
author | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2002-01-17 22:42:15 +0000 |
---|---|---|
committer | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2002-01-17 22:42:15 +0000 |
commit | a1a637c62600bba00c334200770e3f8c8d8adb73 (patch) | |
tree | b34335e833b7483a1b22b156c6cf9b82661a72cb /src/util/File.c | |
parent | 2011f1c1d7db885f2387be95880e822953408884 (diff) |
Check for a race condition in case CCTK_CreateDirectory() is called for the
same directory from multiple procs at the same time.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@2583 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/util/File.c')
-rw-r--r-- | src/util/File.c | 30 |
1 files changed, 2 insertions, 28 deletions
diff --git a/src/util/File.c b/src/util/File.c index cc0bc883..8e42b999 100644 --- a/src/util/File.c +++ b/src/util/File.c @@ -108,24 +108,13 @@ int CCTK_CreateDirectory (int mode, const char *pathname) if (stat (current, &statbuf)) { -#if 0 - CCTK_VInfo ("Cactus", "Creating directory: '%s'", current); -#endif if (MKDIR_WRAPPER (current, mode) == -1) { -#if 0 - CCTK_VWarn (0, __LINE__, __FILE__, "Cactus", - "Failed to create directory '%s'", current); -#endif - retval = -2; + retval = errno == EEXIST ? 1 : -2; } } else if (! S_ISDIR (statbuf.st_mode)) { -#if 0 - CCTK_VWarn (0, __LINE__, __FILE__, "Cactus", - "'%s' exists but is not a directory", current); -#endif retval = -3; } else @@ -146,24 +135,13 @@ int CCTK_CreateDirectory (int mode, const char *pathname) { if (stat (pathname, &statbuf)) { -#if 0 - CCTK_VInfo ("Cactus", "Creating directory: '%s'", pathname); -#endif if (MKDIR_WRAPPER (pathname, mode) == -1) { -#if 0 - CCTK_VWarn (0, __LINE__, __FILE__, "Cactus", - "Failed to create directory '%s'", pathname); -#endif - retval = -2; + retval = errno == EEXIST ? 1 : -2; } } else if (! S_ISDIR (statbuf.st_mode)) { -#if 0 - CCTK_VWarn (0, __LINE__, __FILE__, "Cactus", - "'%s' exists but is not a directory", pathname); -#endif retval = -3; } else @@ -178,10 +156,6 @@ int CCTK_CreateDirectory (int mode, const char *pathname) } else { -#if 0 - CCTK_Warn (0, __LINE__, __FILE__, "Cactus", - "Failed to allocate some temporary memory"); -#endif retval = -1; } |