-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TcpListener: drain all pending accepts (#224)
This commit makes `TcpListener::accept` try to accept the next connection without waiting for a notify, if the previous connection couldn't be established because the peer already went away. The change is meant to fix a bug where a pending connection sometimes wouldn't be accepted. Consider this series of events: * Server runs `TcpListener::accept`. There are no connections pending, so it starts waiting on the `notify`. * Client 1 sends a SYN, which gets pushed to `ServerSocket::deque` and `ServerSocket::notify` is notified. * Client 2 sends a SYN, which gets pushed to `ServerSocket::deque` and `ServerSocket::notify` is notified. * Client 1 goes away. * Server wakes up because the `notify` was notified. * Server tries to accept the connection from client 1, which fails because client 1 went away. * Server starts waiting on the `notify` again. We end up in a situation where the connection from client 2 is still pending but the server doesn't accept it because it's waiting for a notification that was already sent.
- Loading branch information
Showing
2 changed files
with
74 additions
and
26 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