Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CA-387699: Fix Protocol_async.with_lock bug spotted by Vincent
Monadic concurrency libraries can switch away to another 'promise' whenever the bind operator is called. In fact Async will always switch away, but Lwt would only switch away if the promise is blocked (this is probably the origin of the bug). Move the 't.m <- true' next to where we checked that it is false to ensure that we are the only ones holding it. (This is still vulnerable to race conditions with pure OCaml threads, but not with Async promises). Another alternative would be to use Async.Throttle.Sequencer, but this change is a minimal one that could be backported to Yangtze even. Signed-off-by: Edwin Török <[email protected]>
- Loading branch information