diff --git a/ocaml/message-switch/async/protocol_async.ml b/ocaml/message-switch/async/protocol_async.ml index 3575ac268bf..636cfd5e2b4 100644 --- a/ocaml/message-switch/async/protocol_async.ml +++ b/ocaml/message-switch/async/protocol_async.ml @@ -82,13 +82,13 @@ module M = struct let with_lock t f = let rec wait state = - if Bool.(t.m = state) then + if Bool.(t.m = state) then ( + t.m <- true ; return () - else + ) else Condition.wait t.c >>= fun () -> wait state in wait false >>= fun () -> - t.m <- true ; Monitor.protect f ~finally:(fun () -> t.m <- false ; Condition.broadcast t.c () ;