1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

don't use #close_write anymore

git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@708 19e92222-5c0b-0410-8929-a290d50e31e9
This commit is contained in:
evanweaver 2007-10-21 00:49:39 +00:00
parent d665da08ba
commit 638620f70d
2 changed files with 13 additions and 17 deletions

View file

@ -1,10 +1,8 @@
# Minimal test to help debug JRuby socket issues # Minimal test to help debug JRuby socket issues
require 'mongrel' require 'socket'
socket = TCPSocket.new('127.0.0.1', '3000')
include Mongrel socket.write("G")
socket.close_write
@server = HttpServer.new("127.0.0.1", 9997, num_processors=1) socket.write("E")
@server.run
@server.stop(true)

View file

@ -33,7 +33,9 @@ class WebServerTest < Test::Unit::TestCase
end end
def teardown def teardown
@server.stop(true) redirect_test_io do
@server.stop(true)
end
end end
def test_simple_server def test_simple_server
@ -43,24 +45,20 @@ class WebServerTest < Test::Unit::TestCase
def do_test(string, chunk, close_after=nil) def do_test(string, chunk, close_after=nil)
socket = TCPSocket.new("127.0.0.1", 9998); @socket = TCPSocket.new("127.0.0.1", 9998);
request = StringIO.new(string) request = StringIO.new(string)
chunks_out = 0 chunks_out = 0
while data = request.read(chunk) while data = request.read(chunk)
chunks_out += socket.write(data) chunks_out += @socket.write(data)
puts "Chunks: #{chunks_out.inspect}" @socket.flush
socket.flush
sleep 0.2 sleep 0.2
if close_after and chunks_out > close_after if close_after and chunks_out > close_after
puts "** Closing write" @socket.close
socket.close_write
sleep 1 sleep 1
end end
end end
socket.write(" ") if RUBY_PLATFORM =~ /mingw|mswin|cygwin/ @socket.write(" ") # Some platforms only raise the exception on attempted write
socket.close
puts "** Closing entire socket"
end end
def test_trickle_attack def test_trickle_attack