* lib/webrick/server.rb (WEBrick::GenericServer#start): should

restore @token if accept failure. suggested by Dominique Brezinski.
  [ruby-core:04518]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
gotoyuzo 2005-03-07 12:32:07 +00:00
parent 562185ff5c
commit d0f6f9fb7a
2 changed files with 29 additions and 12 deletions

View File

@ -1,3 +1,9 @@
Mon Mar 7 21:29:40 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/server.rb (WEBrick::GenericServer#start): should
restore @token if accept failure. suggested by Dominique Brezinski.
[ruby-core:04518]
Mon Mar 7 21:01:37 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_require_safe): get actual path string under safe level

View File

@ -88,20 +88,15 @@ module WEBrick
if svrs = IO.select(@listeners, nil, nil, 2.0)
svrs[0].each{|svr|
@tokens.pop # blocks while no token is there.
sock = svr.accept
sock.sync = true
if @config[:DoNotReverseLookup]
sock.do_not_reverse_lookup = true
end
Utils::set_close_on_exec(sock)
if sock = accept_client(svr)
th = start_thread(sock, &block)
th[:WEBrickThread] = true
thgroup.add(th)
else
@tokens.push(nil)
end
}
end
rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPROTO => ex
# TCP connection was established but RST segment was sent
# from peer before calling TCPServer#accept.
rescue Errno::EBADF, IOError => ex
# if the listening socket was closed in GenericServer#shutdown,
# IO::select raise it.
@ -143,6 +138,22 @@ module WEBrick
private
def accept_client(svr)
sock = nil
begin
sock = svr.accept
sock.sync = true
Utils::set_close_on_exec(sock)
rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPROTO => ex
# TCP connection was established but RST segment was sent
# from peer before calling TCPServer#accept.
rescue Exception => ex
msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
@logger.error msg
end
return sock
end
def start_thread(sock, &block)
Thread.start{
begin
@ -164,6 +175,7 @@ module WEBrick
rescue Exception => ex
@logger.error ex
ensure
@tokens.push(nil)
Thread.current[:WEBrickSocket] = nil
if addr
@logger.debug "close: #{addr[3]}:#{addr[1]}"
@ -172,7 +184,6 @@ module WEBrick
end
sock.close
end
@tokens.push(nil)
}
end