]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
EEXIST is fine in a system with multiple processes.
authorAlan T. DeKok <aland@freeradius.org>
Thu, 8 Apr 2021 12:44:10 +0000 (08:44 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 8 Apr 2021 12:44:10 +0000 (08:44 -0400)
race conditions on `make -j 8` for example

src/lib/util/file.c

index 0f8227c81ffd8713a0f842001afb2cbcfff8b8c1..2f448cf11a6b9580592189a3f349d913d71e51d7 100644 (file)
@@ -74,12 +74,16 @@ static ssize_t _fr_mkdir(int *fd_out, char const *path, mode_t mode, fr_mkdir_fu
        }
 
        /*
-        *      EEXIST is only OK when we're calling
-        *      mkdir on the whole path, and it exists
-        *      which should have been caught by
-        *      fr_mkdir before calling this function.
+        *      EEXIST is only OK when we're calling mkdir on the
+        *      whole path, and it exists which should have been
+        *      caught by fr_mkdir before calling this function.
+        *
+        *      Unless we're running in an environment with multiple
+        *      processes, in which case EEXIST means that another
+        *      process created this directory in between our check
+        *      and our creation.
         */
-       if (errno != ENOENT) {
+       if ((errno != ENOENT) && (errno != EEXIST)) {
                fr_strerror_printf("Unexpected error creating directory: %s",
                                   fr_syserror(errno));
                goto mkdir_error;