* lib/webrick/server.rb (WEBrick::GenericServer#stop): fix r35303;

this method is to deny new connections, not shutdown yet.

* lib/webrick/server.rb (WEBrick::GenericServer#start):
  re-raise exception only when the exception is Interrupt (^C).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2012-04-13 06:21:50 +00:00
Родитель d2e69f8584
Коммит deb0519aec
3 изменённых файлов: 23 добавлений и 15 удалений

Просмотреть файл

@ -1,3 +1,11 @@
Fri Apr 13 15:17:36 2012 NARUSE, Yui <naruse@ruby-lang.org>
* lib/webrick/server.rb (WEBrick::GenericServer#stop): fix r35303;
this method is to deny new connections, not shutdown yet.
* lib/webrick/server.rb (WEBrick::GenericServer#start):
re-raise exception only when the exception is Interrupt (^C).
Thu Apr 12 19:51:45 2012 Tadayoshi Funaba <tadf@dotrb.org>
* ext/date/date_core.c: added some notes.

Просмотреть файл

@ -133,16 +133,17 @@ module WEBrick
rescue Errno::EBADF, IOError => ex
# if the listening socket was closed in GenericServer#shutdown,
# IO::select raise it.
rescue StandardError => ex
msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
@logger.error msg
rescue Exception => ex
rescue Interrupt => ex # ^C
@logger.fatal ex
raise
rescue Exception => ex
msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
@logger.error msg
end
end
ensure
@status = :Shutdown
@logger.info "going to shutdown ..."
thgroup.list.each{|th| th.join if th[:WEBrickThread] }
call_callback(:StopCallback)
@ -157,7 +158,7 @@ module WEBrick
def stop
if @status == :Running
@status = :Stop
@status = :Shutdown
end
end

Просмотреть файл

@ -29,23 +29,22 @@ class TestWEBrickServer < Test::Unit::TestCase
:StopCallback => Proc.new{ stopped += 1 },
}
e = assert_raises(Exception) do
e = assert_raises(Interrupt) do
TestWEBrick.start_server(Echo, config) { |server, addr, port, log|
listener = server.listeners.first
def listener.accept
raise Exception, 'fatal' # simulate ^C
Process.kill(:INT, $$) # simulate ^C
end
true while server.status != :Running
Thread.pass while server.status != :Running
TCPSocket.open(addr, port) { |sock| sock << "foo\n" }
sleep 0.1 until server.status == :Stop
Thread.pass until server.status == :Stop
}
end
assert_equal('fatal', e.message)
assert_equal(stopped, 1)
end