Skip to content

Commit

Permalink
fix: Fix a linear space calculation bug in BipartiteBuf
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DNedic committed Dec 7, 2023
1 parent 970bdc1 commit b613707
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lockfree/spsc/bipartite_buf_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ T *BipartiteBuf<T, size>::WriteAcquire(const size_t free_required) {
const size_t r = _r.load(std::memory_order_acquire);

const size_t free = CalcFree(w, r);
const size_t linear_space = size - r;
const size_t linear_space = size - w;
const size_t linear_free = std::min(free, linear_space);

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

0 comments on commit b613707

Please sign in to comment.