Commit fba6fed4 authored by Julien Tesson's avatar Julien Tesson
Browse files

Bugfix : counter value was not re-read if compare_and_set failed, could have...

Bugfix : counter value was not re-read if compare_and_set failed, could have triggered infinite loop
parent c5dd9e9f
......@@ -91,8 +91,7 @@ Bsmlsig.BSML
So if counter is at 0, the worker does not wait.
*)
let commit_one_and_wait global_counter main_th =
let counter = Atomic.get global_counter in
while not (Atomic.compare_and_set global_counter counter (counter+1)) do () done;
while not (let counter = Atomic.get global_counter in Atomic.compare_and_set global_counter counter (counter+1)) do () done;
Domain.Sync.notify main_th;
Domain.Sync.critical_section ( fun () ->
if Atomic.get global_counter > 0 then Domain.Sync.wait () else()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment