-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Protect dispatchPeer and toWrite Queue If Opening Connection Closes
Previously, for OpenBSD there was an intermittent issue with Listener::dispatchPeer (which setups a new peer for a new connection) when the client managed to close the connection before dispatchPeer had finished executing. This was causing a throw for peer->fd(), the actual-fd (derived from fd) being used an index into the set of peers, since the peer's fd was empty due to the close. In the changed code, we allow peer-fd() to return an empty fd without a throw, but also use the transport::toWriteLock to guard against the close messing up write attempts and/or new-connection dispatch attempts. Specific changes: peer.h/peer.c: Provide an actualFd() method for peer which can be used when the caller just wants the actual-fd and doesn't need to know the intermediate "fd" value (which the caller would have been previously fetching just to then call getActualFd). Allows us to protect "fd" from getting closed while that actualFd() method is executing. listener.cc: Uses peer->actualFd() as described above. transport.h/transport.cc: Add closeFd(Fd) method to transport.cc. peer.cc then uses this to close the Fd within peer::closeFd(). This allows the transport code to clean its toWrite queue upon the Fd closing. transport.cc: The "clean up buffers" for toWrite is removed from the face of Transport::removePeer, now done in closeFd(Fd). There are also a few places where we check for an Fd being empty, and some comments added pointing out where Fd is now allowed to be empty, where before the empty Fd would have been prevented by a throw.
- Loading branch information
1 parent
46d3be1
commit c62e46d
Showing
7 changed files
with
158 additions
and
65 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
Oops, something went wrong.