-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: race condition in Waiters#add vs Waiters#consume_each
One thread may close a file descriptor or run the evloop and receive an error or hup event, which will wakeup all pending fibers. Further attempts should fail since the fd is closed, but another thread might be trying to add a waiter, which may go unnoticed by `#consume_each` that doesn't manipulate the `@ready` variable. This patch resolves this by distinguishing between ready (we want to wakeup one waiter) and closed (the fd will never go to block anymore). Also simplifies the implementation to rely on the lock, instead of the lock + atomics. We'll see later if the lock is an issue and how to optimize in that case.
- Loading branch information
1 parent
2a84f73
commit 589993b
Showing
5 changed files
with
52 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters