summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/JavaUtil.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2024-02-27 22:45:45 +0100
committerJose <jose@zeroc.com>2024-02-27 22:45:45 +0100
commite545e8bf03ff6771d96f162229276d6287ddca6f (patch)
tree38adeffde97ff5dea9c255076a97ef9ebe4f5c0b /cpp/src/Slice/JavaUtil.cpp
parentFix loading of certificates without password (#1812) (diff)
downloadice-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/Slice/JavaUtil.cpp')
-rw-r--r--cpp/src/Slice/JavaUtil.cpp9
1 files changed, 8 insertions, 1 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);