Fix atomicity violation in try_acquire by using compare_exchange#115
Fix atomicity violation in try_acquire by using compare_exchange#115quantpoet wants to merge 1 commit intorust-lang:mainfrom
Conversation
Signed-off-by: quantpoet <quantway@outlook.com>
Why is this a problem? It looks like an idempotent fcntl call. Also, wouldn't |
|
Worse actually: with this PR, thread A can swap The current implementation ensures |
Oh indeed. Thanks for your reply. |
Replaced the racy load-then-store pattern with atomic compare_exchange to eliminate the potential race condition.
This ensures the non-blocking flag is set atomically, preventing multiple threads from simultaneously calling set_nonblocking on the same file descriptor.