From: Richard W.M. Jones Date: Mon, 7 Oct 2013 10:39:49 +0000 (+0100) Subject: goaljobs: Forgot to close the .goaljobs-memory file! X-Git-Tag: 0.2~7 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=389eaef1047e69836f65ce99301d7a2589083581;p=goaljobs.git goaljobs: Forgot to close the .goaljobs-memory file! --- diff --git a/goaljobs.ml b/goaljobs.ml index f3d27b7..4e3c07b 100644 --- a/goaljobs.ml +++ b/goaljobs.ml @@ -340,6 +340,7 @@ let with_memory_locked ?(write = false) f = let filename = getenv "HOME" // ".goaljobs-memory" in let fd = openfile filename [O_RDWR; O_CREAT] 0o644 in lockf fd (if write then F_LOCK else F_RLOCK) 0; + (* If the file is newly created with zero size, write an * empty hash table. *) @@ -354,6 +355,7 @@ let with_memory_locked ?(write = false) f = (* Run the function. *) let r = try Either (f fd) with exn -> Or exn in lockf fd F_ULOCK 0; + close fd; match r with | Either x -> x | Or exn -> raise exn