diff options
author | Sebastian Andrzej Siewior <sebastian@breakpoint.cc> | 2016-06-10 20:04:51 +0200 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2016-06-23 11:10:29 -0400 |
commit | 70a56b914772e6b21cda2a5742817ae4bb7290f1 (patch) | |
tree | 261e2e1200e26995136754f42a644853ef09f020 /util | |
parent | fe2d149119063ec3c89fd6db9af8a6970e3e6032 (diff) | |
download | openssl-70a56b914772e6b21cda2a5742817ae4bb7290f1.tar.gz |
utils/mkdir-p: check if dir exists also after mkdir failed
with "make install -j8" it happens very often that two or more make
instances are creating the same directory in parallel. As a result one
instace creates the directory and second mkdir fails because the
directory exists already (but it did not while testing for it earlier).
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1204)
Diffstat (limited to 'util')
-rwxr-xr-x | util/mkdir-p.pl | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/util/mkdir-p.pl b/util/mkdir-p.pl index 4f44266802..328060243f 100755 --- a/util/mkdir-p.pl +++ b/util/mkdir-p.pl @@ -33,6 +33,12 @@ sub do_mkdir_p { do_mkdir_p($parent); } - mkdir($dir, 0777) || die "Cannot create directory $dir: $!\n"; + unless (mkdir($dir, 0777)) { + if (-d $dir) { + # We raced against another instance doing the same thing. + return; + } + die "Cannot create directory $dir: $!\n"; + } print "created directory `$dir'\n"; } |