Issue Details (XML | Word | Printable)

Key: JRUBY-94
Type: Bug Bug
Status: Closed Closed
Resolution: Incomplete
Priority: Major Major
Assignee: Charles Oliver Nutter
Reporter: Tim Bray
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JRuby

IO#write doesn't flush sometimes

Created: 17/Aug/06 06:27 PM   Updated: 30/Apr/07 03:17 AM   Resolved: 03/Apr/07 09:05 PM
Return to search
Component/s: Core Classes/Modules
Affects Version/s: JRuby 0.9.0
Fix Version/s: None

Time Tracking:
Not Specified

Environment: OS X, latest JRuby, but observed it on Ubuntu too


 Description  « Hide

If you do a POST using Net::HTTP and the data you're posting doesn't end with \n, it doesn't flush and the server eventually times out. Fixed witih an IO#flush in net/protocol.rb like so:

diff protocol.rb /usr/local/lib/ruby/1.8/net/protocol.rb
14c14
< # $Id: protocol.rb,v 1.2 2006/06/10 19:14:11 headius Exp $

> # $Id: protocol.rb,v 1.73.2.3 2005/09/13 07:27:18 aamine Exp $
153d152
< @io.flush



Thomas E Enebo added a comment - 21/Aug/06 08:25 PM

Adding @io.flush would wallpaper the actual problem (it should be flushing without this). Are you sure this is latest trunk? Or is it 0.9.0? JRUBY-52 had a similiar problem this month and it has been fixed since then. At least it fixes the following test:

Server:

require 'socket'

serv = TCPServer.new('localhost',2202)
sock = serv.accept

puts sock.read(5)
sock.write "world!"
sock.close

Client:

require 'socket'

socket = TCPSocket.new("localhost",2202)

socket.write "Hello"
puts socket.read(6)
socket.close

A HTTP POST creates a TCPSocket and then wraps it with protocol.rb's BufferedIO. I would think with the following code above working we should be golden per your description of the problem. If you are using trunk, then could you run the client and server above and make sure this test is working?


Miguel Covarrubias added a comment - 31/Dec/06 05:54 PM

Is there still a lack of flushing under some circumstances? I've not been able to reproduce this problem.


Charles Oliver Nutter added a comment - 03/Apr/07 09:05 PM

We need a test case for this, or at least to have it revisited on a more recent JRuby. Marking as incomplete; reopen if it's actually still broken for a reproducible test case.


Charles Oliver Nutter added a comment - 30/Apr/07 03:17 AM

Closing resolved issues that were never attached to a release (mostly invalid, wontfix, dupes, or incomplete).