From afdc0c9b1ce68c051239f0a5215cfdbd217b28fa Mon Sep 17 00:00:00 2001 From: evanweaver Date: Mon, 22 Oct 2007 06:22:48 +0000 Subject: do_test needs to be threadsafe git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@727 19e92222-5c0b-0410-8929-a290d50e31e9 --- test/test_ws.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/test_ws.rb b/test/test_ws.rb index 5ea5a16..33981c6 100644 --- a/test/test_ws.rb +++ b/test/test_ws.rb @@ -45,22 +45,21 @@ class WebServerTest < Test::Unit::TestCase def do_test(string, chunk, close_after=nil) - @socket = TCPSocket.new("127.0.0.1", 9998); + # Do not use instance variables here, because it needs to be thread safe + socket = TCPSocket.new("127.0.0.1", 9998); request = StringIO.new(string) chunks_out = 0 -# STDERR.puts chunks_out while data = request.read(chunk) - chunks_out += @socket.write(data) -# STDERR.puts chunks_out - @socket.flush + chunks_out += socket.write(data) + socket.flush sleep 0.2 if close_after and chunks_out > close_after - @socket.close + socket.close sleep 1 end end - @socket.write(" ") # Some platforms only raise the exception on attempted write + socket.write(" ") # Some platforms only raise the exception on attempted write end def test_trickle_attack -- cgit v1.2.3-24-ge0c7