diff --git a/src/ring_buffer/spsc.rs b/src/ring_buffer/spsc.rs index 082aab71441c92796e2a9ee0c1c4a0e1beb5aadb..4260baec7b143a32f3a0f13c37c88f9cd1ac02fd 100644 --- a/src/ring_buffer/spsc.rs +++ b/src/ring_buffer/spsc.rs @@ -88,8 +88,8 @@ where let n = rb.capacity() + 1; let buffer: &mut [T] = unsafe { rb.buffer.as_mut() }; - let head = rb.head.load_relaxed(); let tail = rb.tail.load_relaxed(); + let head = rb.head.load_acquire(); let next_tail = (tail + 1) % n; if next_tail != head { // NOTE(ptr::write) the memory slot that we are about to write to is uninitialized. We diff --git a/tests/tsan.rs b/tests/tsan.rs index 9fbcb8d59b553bd6c513f63872db9595566244b1..07def1462c61ff639a8e7652a4bc72e382b4e95e 100644 --- a/tests/tsan.rs +++ b/tests/tsan.rs @@ -87,7 +87,7 @@ fn contention() { scope.execute(move || { let mut sum: u32 = 0; - for i in 0..N { + for i in 0..(2*N) { let i = i as u8; sum = sum.wrapping_add(i as u32); while let Err(_) = p.enqueue(i) {} @@ -99,7 +99,7 @@ fn contention() { scope.execute(move || { let mut sum: u32 = 0; - for _ in 0..N { + for _ in 0..(2*N) { loop { match c.dequeue() { Some(v) => {