From 6226ce9daf783b05b3299ce4518f7a54853c9e92 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Thu, 8 Apr 2021 08:44:10 -0400 Subject: [PATCH] EEXIST is fine in a system with multiple processes. race conditions on `make -j 8` for example --- src/lib/util/file.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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; -- 2.47.2