mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-08 20:25:28 -05:00
Merge pull request #94 from mseri/patch-1
Fix `CCSemaphore.with_acquire`: release a non locked mutex is UB (thanks to @mseri)
This commit is contained in:
commit
c359b3d570
1 changed files with 3 additions and 4 deletions
|
|
@ -53,14 +53,13 @@ let release m t =
|
|||
*)
|
||||
|
||||
let with_acquire ~n t ~f =
|
||||
Mutex.lock t.mutex;
|
||||
acquire_once_locked_ n t;
|
||||
acquire n t;
|
||||
try
|
||||
let x = f() in
|
||||
release_once_locked_ n t;
|
||||
release n t;
|
||||
x
|
||||
with e ->
|
||||
release_once_locked_ n t;
|
||||
release n t;
|
||||
raise e
|
||||
|
||||
(*$R
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue