fix a bug when the synchronizer was closed but still has some elements and one where we would not end a pledge in case of failure#5
Merged
redianthus merged 1 commit intomainfrom Dec 14, 2025
Conversation
redianthus
commented
Dec 12, 2025
| let get ?(pledge = true) synchro = | ||
| let rec inner_loop pledge synchro = | ||
| match synchro.getter () with | ||
| | None when synchro.pledges = 0 || synchro.closed -> |
Member
Author
There was a problem hiding this comment.
I believe this was wrong @krtab. It may have been that you parsed it as:
| (None when synchro.pledges = 0) || (synchro.closed) ->Whereas it is really:
| None when ((synchro.pledges = 0) || (synchro.closed)) ->It means that if the synchronizer was closed but nonempty, then we would still return stuff from it, leading to a lot of unexpected behaviors...
The fix is to check if the synchronizer was closed first without looking at if it is empty or not.
8f0603b to
b26ae63
Compare
`end_plege` is called in `work_while` when the function fails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cc @krtab
There was a bug here: https://github.com/OCamlPro/synchronizer/pull/5/changes#r2614774996
I also added a
Fun.protectinwork_whileto make sure the pledge is ended even if the function fails. Other changes are simply cleaning.