Olaf Hering
ecc4cee8e6
Fix racing mkdirs OBS-URL: https://build.opensuse.org/request/show/401778 OBS-URL: https://build.opensuse.org/package/show/devel:languages:ocaml/ocaml-parmap?expand=0&rev=8
24 lines
782 B
Diff
24 lines
782 B
Diff
diff --git a/parmap.ml b/parmap.ml
|
|
index f781d96..c0954fd 100644
|
|
--- a/parmap.ml
|
|
+++ b/parmap.ml
|
|
@@ -42,10 +42,14 @@ let can_redirect path =
|
|
try
|
|
Unix.mkdir path 0o777; true
|
|
with Unix.Unix_error(e,_s,_s') ->
|
|
- (Printf.eprintf "[Pid %d]: Error creating %s : %s; proceeding without \
|
|
- stdout/stderr redirection\n%!"
|
|
- (Unix.getpid ()) path (Unix.error_message e));
|
|
- false
|
|
+ (* another job may have created it between the check and the mkdir *)
|
|
+ if e == Unix.EEXIST then true
|
|
+ else begin
|
|
+ (Printf.eprintf "[Pid %d]: Error creating %s : %s; proceeding \
|
|
+ without stdout/stderr redirection\n%!"
|
|
+ (Unix.getpid ()) path (Unix.error_message e));
|
|
+ false
|
|
+ end
|
|
else true
|
|
|
|
let log_debug fmt =
|