Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a benign data-race in Chan reported by ocaml-tsan #103

Merged
merged 1 commit into from
Apr 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/chan.ml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ let rec send' {buffer_size; contents} v ~polling =
let new_contents = Empty {receivers= receivers'} in
if Atomic.compare_and_set contents old_contents new_contents
then begin
r := Some v;
Mutex.lock mc.mutex;
r := Some v;
Mutex.unlock mc.mutex;
Condition.broadcast mc.condition;
true
Expand Down Expand Up @@ -192,8 +192,8 @@ let rec recv' {buffer_size; contents} ~polling =
in
if Atomic.compare_and_set contents old_contents new_contents
then begin
c := Notified;
Mutex.lock mc.mutex;
c := Notified;
Mutex.unlock mc.mutex;
Condition.broadcast mc.condition;
Some m
Expand All @@ -206,8 +206,8 @@ let rec recv' {buffer_size; contents} ~polling =
in
if Atomic.compare_and_set contents old_contents new_contents
then begin
sc := Notified;
Mutex.lock mc.mutex;
sc := Notified;
Mutex.unlock mc.mutex;
Condition.broadcast mc.condition;
Some m
Expand Down