diff options
author | Jose <jose@zeroc.com> | 2024-02-27 22:45:45 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2024-02-27 22:45:45 +0100 |
commit | e545e8bf03ff6771d96f162229276d6287ddca6f (patch) | |
tree | 38adeffde97ff5dea9c255076a97ef9ebe4f5c0b /cpp/src | |
parent | Fix loading of certificates without password (#1812) (diff) | |
download | ice-e545e8bf03ff6771d96f162229276d6287ddca6f.tar.bz2 ice-e545e8bf03ff6771d96f162229276d6287ddca6f.tar.xz ice-e545e8bf03ff6771d96f162229276d6287ddca6f.zip |
Fixed concurrent directory creation issue in the Slice compilers - #1846
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Slice/JavaUtil.cpp | 9 | ||||
-rw-r--r-- | cpp/src/slice2matlab/Main.cpp | 9 |
2 files changed, 16 insertions, 2 deletions
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 9ad435fbae7..b2ad3602631 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -754,7 +754,14 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix, const stri continue; } - if(IceUtilInternal::mkdir(path, 0777) != 0) + int err = IceUtilInternal::mkdir(path, 0777); + // If slice2java is run concurrently, it's possible that another instance of slice2java has already + // created the directory. + if (err == 0 || (errno == EEXIST && IceUtilInternal::directoryExists(path))) + { + // Directory successfully created or already exists. + } + else { ostringstream os; os << "cannot create directory `" << path << "': " << IceUtilInternal::errorToString(errno); diff --git a/cpp/src/slice2matlab/Main.cpp b/cpp/src/slice2matlab/Main.cpp index 681664126b6..51b507aff70 100644 --- a/cpp/src/slice2matlab/Main.cpp +++ b/cpp/src/slice2matlab/Main.cpp @@ -283,7 +283,14 @@ openClass(const string& abs, const string& dir, IceUtilInternal::Output& out) path += "+" + lookupKwd(v[i]); if(!IceUtilInternal::directoryExists(path)) { - if(IceUtilInternal::mkdir(path, 0777) != 0) + int err = IceUtilInternal::mkdir(path, 0777); + // If slice2matlab is run concurrently, it's possible that another instance of slice2matlab has already + // created the directory. + if (err == 0 || (errno == EEXIST && IceUtilInternal::directoryExists(path))) + { + // Directory successfully created or already exists. + } + else { ostringstream os; os << "cannot create directory `" << path << "': " << IceUtilInternal::errorToString(errno); |