diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-08 01:17:07 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-08 01:17:07 +0000 |
commit | 719804b5df99feb8f8b871051d64bdd73524511f (patch) | |
tree | d3629fdb8fcf5ba8040fdfcf125d5b5ad42da496 /lib | |
parent | b9f770ae8ffe2c5f83b5f411534c6d5c2f687345 (diff) | |
download | ruby-719804b5df99feb8f8b871051d64bdd73524511f.tar.gz |
webrick/httpserver.rb: Stop handling requests on shutdown
* lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): stop
handling requests on shutdown, even if the socket is readable
and IO.select() returns true. [Fixes GH-607]
* lib/webrick/server.rb (WEBrick::GenericServer#start): IO.select()
raises ENOTSOCK on shutdown on Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/webrick/httpserver.rb | 4 | ||||
-rw-r--r-- | lib/webrick/server.rb | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/webrick/httpserver.rb b/lib/webrick/httpserver.rb index 7a7b931dad..0618489c53 100644 --- a/lib/webrick/httpserver.rb +++ b/lib/webrick/httpserver.rb @@ -73,10 +73,10 @@ module WEBrick timeout = @config[:RequestTimeout] while timeout > 0 break if IO.select([sock], nil, nil, 0.5) - timeout = 0 if @status != :Running + break if @status != :Running timeout -= 0.5 end - raise HTTPStatus::EOFError if timeout <= 0 + raise HTTPStatus::EOFError if timeout <= 0 || @status != :Running raise HTTPStatus::EOFError if sock.eof? req.parse(sock) res.request_method = req.request_method diff --git a/lib/webrick/server.rb b/lib/webrick/server.rb index 3f5371ba47..bd8a045891 100644 --- a/lib/webrick/server.rb +++ b/lib/webrick/server.rb @@ -180,7 +180,7 @@ module WEBrick end } end - rescue Errno::EBADF, IOError => ex + rescue Errno::EBADF, Errno::ENOTSOCK, IOError => ex # if the listening socket was closed in GenericServer#shutdown, # IO::select raise it. rescue StandardError => ex |