You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under MRI, the following code will result in fetching https://www.google.com/. The last two lines are "0" and blank (chunked transfer encoding over http).
However, under JRuby (tested JRuby 1.7.16.1 and 1.7.9), this hangs.
Under MRI, it successfully reads the full HTTP request and the last line output (bytes read) is 52460. However, under JRuby, it hangs in IO::select after about the 30th iteration, but is nondeterministic in behavior (though the nondeterminism may be due to Google's webservers varying its responses and variations in TCP timing).
Jruby last output example:
29: 39149
30: 40542
31: 41935
In general, JRuby gets about 30 or 31 iterations (IO::select + sysread), and around 38kb-40kb of data before the next IO::select blocks forever.
If I change the timeout in IO::select to be 1 second instead of nil, the IO::select will time out after 1 second AND the next sysread() will give me data.
@jordansissel Hello! This is fairly old but I was researching non-blocking.
I think in your test though it is likely wanting to write due to a key exchange, which can sometimes happen in the middle of a read. So you should IO.select([o], [o], nil, nil) just to be sure.
@driskell yeah I remember that being necessary when using OpenSSL from C, but in C we're doing select on the fd, not the openssl object as we are in Ruby, so I"m not sure - you might be totally right! :P
It's been a while, so my memory is fuzzy. I'll revisit this soon :P
Under MRI, the following code will result in fetching https://www.google.com/. The last two lines are "0" and blank (chunked transfer encoding over http).
However, under JRuby (tested JRuby 1.7.16.1 and 1.7.9), this hangs.
Under MRI, it successfully reads the full HTTP request and the last line output (bytes read) is 52460. However, under JRuby, it hangs in IO::select after about the 30th iteration, but is nondeterministic in behavior (though the nondeterminism may be due to Google's webservers varying its responses and variations in TCP timing).
Jruby last output example:
In general, JRuby gets about 30 or 31 iterations (IO::select + sysread), and around 38kb-40kb of data before the next IO::select blocks forever.
If I change the timeout in IO::select to be 1 second instead of nil, the IO::select will time out after 1 second AND the next sysread() will give me data.
Full code:
The text was updated successfully, but these errors were encountered: