From: Alan T. DeKok Date: Thu, 8 Apr 2021 12:44:10 +0000 (-0400) Subject: EEXIST is fine in a system with multiple processes. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6226ce9daf783b05b3299ce4518f7a54853c9e92;p=thirdparty%2Ffreeradius-server.git EEXIST is fine in a system with multiple processes. race conditions on `make -j 8` for example --- diff --git a/src/lib/util/file.c b/src/lib/util/file.c index 0f8227c81f..2f448cf11a 100644 --- a/src/lib/util/file.c +++ b/src/lib/util/file.c @@ -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;