summaryrefslogtreecommitdiff
path: root/test/webrick
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-10 11:05:00 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-10 11:05:00 +0000
commit33bb38a644c62edadec677465b2b08eea4756593 (patch)
tree874f34213585bda9bedebebb79f8eb01d2a3ad3c /test/webrick
parentfd9f6bde957ce681fed49182be02124ecc89b362 (diff)
* lib/webrick/server.rb: Setup shutdown pipe in listen method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/webrick')
-rw-r--r--test/webrick/test_server.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/webrick/test_server.rb b/test/webrick/test_server.rb
index f765da6..043d439 100644
--- a/test/webrick/test_server.rb
+++ b/test/webrick/test_server.rb
@@ -96,4 +96,36 @@ class TestWEBrickServer < Test::Unit::TestCase
w.close
end
end
+
+ def test_restart
+ address = '127.0.0.1'
+ port = 0
+ log = []
+ config = {
+ :BindAddress => address,
+ :Port => port,
+ :Logger => WEBrick::Log.new(log, WEBrick::BasicLog::WARN),
+ }
+ server = Echo.new(config)
+ client_proc = lambda {|str|
+ begin
+ ret = server.listeners.first.connect_address.connect {|s|
+ s.write(str)
+ s.close_write
+ s.read
+ }
+ assert_equal(str, ret)
+ ensure
+ server.shutdown
+ end
+ }
+ server_thread = Thread.new { server.start }
+ client_thread = Thread.new { client_proc.call("a") }
+ assert_join_threads([client_thread, server_thread])
+ server.listen(address, port)
+ server_thread = Thread.new { server.start }
+ client_thread = Thread.new { client_proc.call("b") }
+ assert_join_threads([client_thread, server_thread])
+ assert_equal([], log)
+ end
end