Skip to content

Commit b613707

Browse files
committed
fix: Fix a linear space calculation bug in BipartiteBuf
This fixes a bug where the linear space until the end of the buffer was not calculated correctly. In debug builds, an assert would trigger however for release there could be data corruption.
1 parent 970bdc1 commit b613707

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lockfree/spsc/bipartite_buf_impl.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ T *BipartiteBuf<T, size>::WriteAcquire(const size_t free_required) {
6060
const size_t r = _r.load(std::memory_order_acquire);
6161

6262
const size_t free = CalcFree(w, r);
63-
const size_t linear_space = size - r;
63+
const size_t linear_space = size - w;
6464
const size_t linear_free = std::min(free, linear_space);
6565

6666
/* Try to find enough linear space until the end of the buffer */

0 commit comments

Comments
 (0)