-
-
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
JRuby 9.0.0.0.pre2 starts hanging while reading from a socket #2957
Comments
I'll have a look. |
It seems like it's not getting an EOF, or not handling end of data properly. I added some printing to show how much of the response comes back, and it seems to get the full content but does not EOF (which would let the read return):
|
Ok, this is interesting. If I make the content of the response non-empty, it doesn't hang. Something about content-length=0 is causing this. I suspect there's something preventing the socket from getting closed when content-length=0, and assuming this works ok in MRI it would mean that JRuby's not closing the stream. |
I guess it is the last one because it is not hanging on JRuby 1.7 (see https://travis-ci.org/puma/puma/jobs/63112451) |
I think I've found the issue. Because we often (usually) use JDK streams for most types of IO, we have to emulate errno behavior to match C's write(2). My logic there was producing an errno of EAGAIN whenever zero data could be written to a nonblocking stream. However in this case, it's a zero-length write, so it should just report that it wrote 0 rather than marking EAGAIN. Fix should be coming shortly. |
Great, thanks! I hope my catch helped a bit to improve JRuby :) |
@deepj Indeed it did! This is a peculiar edge case we must not have had any test cases for. |
I have added running Puma server tests under
JRuby 9k
(see puma/puma#701 including Travis https://travis-ci.org/puma/puma/jobs/63116729). There is one test there causing that hanging: https://github.com/puma/puma/blob/master/test/test_puma_server.rb#L207I haven't debug it deeply but it seems it is caused by reading from a socket. I got the same issue as on Travis on my local machine with these settings:
The text was updated successfully, but these errors were encountered: