TCPServer in the midst of accept should still be usable after being
Thread.raise interrupted
--------------------------------------------------------------------------------------------
Key: JRUBY-1452
URL: http://jira.codehaus.org/browse/JRUBY-1452
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Reporter: Charles Oliver Nutter
Fix For: JRuby 1.1.0
Our TCPServer.accept impl does a normal blocking accept. However if another
Ruby thread wants to wake the accepting thread up, it ends up destroying the
socket channel associated with the server. What's needed is to use a
non-blocking accept and a selector to safely sleep until there's an accept
event ready; interrupts during the select will then just wake the thread up and
allow it to check for kill/raise events.
I have a local patch I'm testing, and will commit it and the following test
case shortly:
{noformat}
# test that raising inside an accepting thread doesn't nuke the socket
tcp = TCPServer.new(nil, 5000)
ok = false
exception = nil
t = Thread.new {
begin
tcp.accept
rescue Exception => e
exception = e
# this would normally blow up if the socket was demolished
tcp.close
ok = true
end
}
1 until t.alive?
t.raise
sleep 0.1
test_ok ok
test_ok RuntimeError === exception
{noformat}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.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