-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TCPServer.for_fd raises IOError: closed stream #4715
Comments
Just to confirm this isn't a recent regression, on jruby 1.7.27 the Error is different but raised in the same place:
|
The problem is, that jruby is looking into a map of existing (registered) file descriptors, but if you use a descriptor that wasn't created inside jruby process it fails. |
Yes, this is not an easy one to fix. Our socket logic is based around JVM APIs, which means a TCPSocket always needs a Java TCPSocket underneath it. At the same time, we do try to carve out the real filedescriptor, usually without storing it somewhere. Then when you try to for_fd, we see a real FD, find no existing TCPSocket, and are unable to produce one. This is another one that will be fixed by going with a fully-native socket API, likely in 9.2. See #4748 and others. |
This never happened for 9.2 and is certainly too big for a maintenance release. |
This would be fixed by supporting the FFI-based socket library, and is superseded by #6334. Until then it is not possible to resolve, since we can't create a TCPServer on the JDK from a raw file descriptor. |
I originally encountered this and reported it as puma/puma#1367. I'm reporting it here because its a jruby-specific issue and I intend to provide a minimized reproduction outside of Puma.
I find other references to
for_fd()
possibly being implemented on jruby: #940, #3494 Only for UNIX Server/Socket? It is possible to just do the same thing for TCP Server/Socket?Minimum test ruby script is below. This can be easily tested on a Linux system with systemd and its testing command
systemd-socket-activate
, then usingnc
for the connecting client. These commands should be available on all recent mainstream Linux distributions including Debian (8+), Ubuntu (16+), Fedora, Arch, etc.activate.rb
Run as follows (substitute jruby as needed):
Run this in one terminal, then use
nc
in another terminal to connect to the socket. (You will need to ^C to disconnect.) This is shown below with a successful (MRI ruby) run:With MRI ruby the output on the server side is the following expected output:
With jruby 9.1, an IOError is instead raised from the initial for_fd call:
The text was updated successfully, but these errors were encountered: