TCPSockets do not stay fully closed
-----------------------------------
Key: JRUBY-1460
URL: http://jira.codehaus.org/browse/JRUBY-1460
Project: JRuby
Issue Type: Bug
Reporter: Evan Weaver
Assignee: Thomas E Enebo
Priority: Critical
Note this small, if confusing, test script:
{{{
# Minimal test to help debug JRuby socket issues
require 'socket'
@server = Thread.new do
server_socket = TCPServer.new('0.0.0.0', 10101)
this_client = server_socket.accept
4.times do |n|
begin
data = this_client.readpartial(4)
puts "Server got: #{data}"
if n == 0
this_client.close
puts "Server closed the client"
end
rescue IOError => e
puts "Server has: #{e.inspect}"
end
sleep(1)
end
server_socket.close
end
sleep(3)
client_socket = TCPSocket.new('0.0.0.0', 10101)
4.times do |n|
string = "X#{n}"
begin
client_socket.write(string)
puts "Client said: #{string}"
rescue Errno::EPIPE => e
puts "Client has: #{e.inspect}"
end
sleep(1)
end
client_socket.close
@server.join
}}}
On MRI, we have the expected behavior:
{{{
chloe:~/p/mongrel eweaver$ ruby test/jruby_socket.rb
Client said: X0
Server got: X0
Server closed the client
Server has: #<IOError: closed stream>
Client said: X1
Server has: #<IOError: closed stream>
Client has: #<Errno::EPIPE: Broken pipe>
Server has: #<IOError: closed stream>
Client has: #<Errno::EPIPE: Broken pipe>
}}}
On JRuby, however, the client never stops sending data, and even more
surprisingly, the server errors (with a missing explanation), then receives the
original data again, and finally receives nothing but doesn't error.
{{{
chloe:~/p/mongrel eweaver$ jruby test/jruby_socket.rb
Client said: X0
Server got: X0
Server closed the client
Client said: X1
Server has: #<IOError: No message available>
Client said: X2
Server got: X0
Client said: X3
Server got:
}}}
This appears to be a relatively critical socket issue, if you expect to be able
to rescue exceptions accurately.
--
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