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 buf pool #98

Merged
merged 2 commits into from
Jun 27, 2024
Merged

Fix buf pool #98

merged 2 commits into from
Jun 27, 2024

Conversation

wsong83
Copy link
Member

@wsong83 wsong83 commented Jun 27, 2024

Making the pool state as anatomic variable is not safe enough to protect the buffer pool. When returning a buffer, the buffer state is updated atomically. Another thread may waiting on this event and immediately allocate this buffer before the actual pointer is written back to the pool. As a result, the waiting thread may write on a stale buffer and lead to silent data corruption later on.

The solution is reverting back to the mutex lock which guarantee both the pool and the state are updated as a bundle.

wsong83 added 2 commits June 27, 2024 11:06
Making the pool state as anatomic variable is not safe enough to protect
the buffer pool. When returning a buffer, the buffer state is updated
atomically. Another thread may waiting on this event and immediately
allocate this buffer before the actual pointer is written back to the
pool. As a result, the waiting thread may write on a stale buffer and
lead to silent data corruption later on.

The solution is reverting back to the mutex lock which guarantee both the
pool and the state are updated as a bundle.
@wsong83 wsong83 added this pull request to the merge queue Jun 27, 2024
Merged via the queue into master with commit d473a32 Jun 27, 2024
1 check passed
@wsong83 wsong83 deleted the fix-buf-pool branch June 27, 2024 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant