Skip to content

Commit a43b54a

Browse files
authored
Merge pull request #103 from art-w/tsan
Fix a benign data-race in Chan reported by ocaml-tsan
2 parents 8444619 + 5b2d704 commit a43b54a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/chan.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ let rec send' {buffer_size; contents} v ~polling =
8686
let new_contents = Empty {receivers= receivers'} in
8787
if Atomic.compare_and_set contents old_contents new_contents
8888
then begin
89-
r := Some v;
9089
Mutex.lock mc.mutex;
90+
r := Some v;
9191
Mutex.unlock mc.mutex;
9292
Condition.broadcast mc.condition;
9393
true
@@ -192,8 +192,8 @@ let rec recv' {buffer_size; contents} ~polling =
192192
in
193193
if Atomic.compare_and_set contents old_contents new_contents
194194
then begin
195-
c := Notified;
196195
Mutex.lock mc.mutex;
196+
c := Notified;
197197
Mutex.unlock mc.mutex;
198198
Condition.broadcast mc.condition;
199199
Some m
@@ -206,8 +206,8 @@ let rec recv' {buffer_size; contents} ~polling =
206206
in
207207
if Atomic.compare_and_set contents old_contents new_contents
208208
then begin
209-
sc := Notified;
210209
Mutex.lock mc.mutex;
210+
sc := Notified;
211211
Mutex.unlock mc.mutex;
212212
Condition.broadcast mc.condition;
213213
Some m

0 commit comments

Comments
 (0)