IO#sysread on an accepted socket randomly fails
-----------------------------------------------
Key: JRUBY-3020
URL: http://jira.codehaus.org/browse/JRUBY-3020
Project: JRuby
Issue Type: Bug
Affects Versions: JRuby 1.1.4
Reporter: Wayne Meissner
Assignee: Thomas E Enebo
When running the following code, the sysread will randomly fail with an EOF
exception.
{noformat}
require 'socket'
iter = 50000
PORT = 2000
serv = TCPServer.new('localhost', PORT)
Thread.new {
len = 4096
buf = 0.chr * len
loop do
client = serv.accept
total = 0
begin
loop do
s = client.sysread(len, buf)
total += s.length if s
end
rescue Exception => ex
puts "sysread failed total=#{total}: #{ex}"
end
puts "client closed total=#{total}"
client.close
end
}
loop do
buf = 0.chr * 1
TCPSocket.open('localhost', PORT) do |sock|
iter.times { sock.write buf }
end
end
{noformat}
If the client connect/write loop is taken out, and the server socket is
connected to with e.g. netcat/nc, then the same thing happens - sysread fails
apparently at random.
This may due to be the same root cause as JRUBY-2940. The NIO
ReadableByteChannel#read() call is returning zero bytes, which should not be
possible on a blocking socket.
--
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