mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-10 13:13:56 -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 =
|
let with_acquire ~n t ~f =
|
||||||
Mutex.lock t.mutex;
|
acquire n t;
|
||||||
acquire_once_locked_ n t;
|
|
||||||
try
|
try
|
||||||
let x = f() in
|
let x = f() in
|
||||||
release_once_locked_ n t;
|
release n t;
|
||||||
x
|
x
|
||||||
with e ->
|
with e ->
|
||||||
release_once_locked_ n t;
|
release n t;
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
(*$R
|
(*$R
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue