Repository navigation
Register the descriptor returned by TCPServer and UNIXServer#sysaccept - #9818
Open
sampokuokkanen wants to merge 2 commits into
Open
sampokuokkanen wants to merge 2 commits into
sampokuokkanen wants to merge 2 commits into
Conversation
TCPServer#sysaccept returned the raw fileno without registering it, so Socket.for_fd and TCPSocket.for_fd on it failed with EBADF and IOError. UNIXServer#sysaccept built a UNIXSocket only to return its fd, and when that object was collected its finalizer closed the caller's descriptor. Both now wrap the accepted channel in a ChannelFD, which registers the descriptor and sets close-on-exec, without an IO object to finalize.
While another thread has the server channel nonblocking, for IO.select or accept_nonblock, it can take the connection between our select and accept, and jnr-unixsocket's accept then returns null. accept wrapped that into a UNIXSocket with no connection, and sysaccept raised a NullPointerException. Go back to waiting instead, like TCPServer#sysaccept.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TCPServer#sysaccept returned the raw fileno without registering it, so Socket.for_fd and TCPSocket.for_fd on it failed with EBADF and IOError.
UNIXServer#sysaccept built a UNIXSocket only to return its fd, and when that object was collected its finalizer closed the caller's descriptor.
Both now wrap the accepted channel in a ChannelFD, which registers the descriptor and sets close-on-exec, without an IO object to finalize.
Also added a null check in UNIXServer's accept, like TCPServer#sysaccept already has.
Found by @albertalef in #9813 (comment).