Jordan Sissel created JRUBY-6528: ------------------------------------ Summary: Socket#connect_nonblock and IO::select appear to be misbehaving? Key: JRUBY-6528 URL: https://jira.codehaus.org/browse/JRUBY-6528 Project: JRuby Issue Type: Bug Affects Versions: JRuby 1.6.6, JRuby 1.6.7 Reporter: Jordan Sissel Assignee: Thomas E Enebo
I'm working on some socket code that uses IO.select() and Socket#connect_nonblock to do connects with timeout, pretty much in the same way as the Ruby MRI docs have example code(1) for such: I have sample code that works fine in MRI 1.9.x And 1.8.x, but not JRuby 1.6.7 (in either 1.8 or 1.9 modes) Sample code: https://github.com/jordansissel/experiments/blob/master/ruby/sockets/connect-nonblock.rb Here is the output running under many different rubies: {noformat} {:version=>"1.9.2 @ jruby-1.6.5", :socket=>nil} {:version=>"1.9.2 @ ruby", :socket=>#<Socket:fd 3>} {:version=>"1.9.2 @ jruby-1.6.6", :socket=>nil} {:version=>"1.9.3 @ ruby", :socket=>#<Socket:fd 5>} {:version=>"1.9.2 @ jruby-1.6.7", :socket=>nil} {noformat} The problem appears to be the behavior of IO.select. In my sample code, I expect the 'writer' to be an array containing the socket - when the socket is connected. JRuby seems to not do this: {noformat} reader, writer, error = IO.select(nil, [socket], nil, timeout) p :version => PLATFORM, :writer => writer {noformat} output: {noformat} {:version=>"1.8.7 @ jruby-1.6.5", :writer=>nil} {:version=>"1.9.2 @ ruby", :writer=>[#<Socket:fd 3>]} {:version=>"1.8.7 @ jruby-1.6.6", :writer=>nil} {:version=>"1.9.3 @ ruby", :writer=>[#<Socket:fd 5>]} {:version=>"1.8.7 @ jruby-1.6.7", :writer=>nil} {noformat} (1) See 'example code' from MRI docs http://ruby-doc.org/stdlib-1.9.3/libdoc/socket/rdoc/Socket.html#method-i-connect_nonblock -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email