[Pkg-ocaml-maint-commits] [SCM] approx upstream and debian packaging branch, upstream, updated. debian/2.06-22-gfdc1649

Eric Cooper ecc at cmu.edu
Fri Oct 24 16:04:25 UTC 2008


The following commit has been merged in the upstream branch:
commit a0d06083330928d2d48ee52d227d253a519a9fa1
Author: Eric Cooper <ecc at cmu.edu>
Date:   Thu Oct 16 14:42:23 2008 -0400

    avoid race condition when creating directory for cache file

diff --git a/approx.ml b/approx.ml
index e0e546c..5b17a46 100644
--- a/approx.ml
+++ b/approx.ml
@@ -132,13 +132,19 @@ let serve_local name ims env =
       else Missing
 
 let make_directory path =
+  (* Create a directory component in the path.  Since it might be
+     created concurrently, we have to ignore the Unix EEXIST error --
+     simply testing for existence first introduces a race condition. *)
+  let make_dir name =
+    try mkdir name 0o755
+    with Unix_error (EEXIST, _, _) ->
+      if not (Sys.is_directory name) then
+        failwith ("file " ^ name ^ " is not a directory")
+  in
   let rec loop cwd = function
     | dir :: rest ->
         let name = cwd ^/ dir in
-        if not (Sys.file_exists name) then
-          mkdir name 0o755
-        else if not (Sys.is_directory name) then
-          failwith ("file " ^ name ^ " is not a directory");
+        make_dir name;
         loop name rest
     | [] -> ()
   in

-- 
approx upstream and debian packaging



More information about the Pkg-ocaml-maint-commits mailing list