summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-18 14:43:03 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-18 14:43:03 +0000
commit26591946f27ed9dc2902ffd63a72e053b6cee433 (patch)
treede21f112d9f6f935a2f9a744b4ff453ad51c8cb2 /lib
parentd5d58b892dd1771ded9b8161348752bcb980ef8f (diff)
downloadruby-26591946f27ed9dc2902ffd63a72e053b6cee433.tar.gz
ruby-26591946f27ed9dc2902ffd63a72e053b6cee433.tar.xz
ruby-26591946f27ed9dc2902ffd63a72e053b6cee433.zip
* lib/webrick/server.rb (WEBrick::GenericServer#accept_client):
should rescue Errno::EINVAL from TCPServer#accept. this exception might occur if the server socket is not in ready to listen. * lib/webrick/server.rb (WEBrick::GenericServer#accept_client): don't call TCPServer#close if the :ShutdownSocketWithoutClose is set. * lib/webrick/config.rb (WEBrick::Config::General): add new parameter :ShutdownSocketWithoutClose. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/webrick/config.rb1
-rw-r--r--lib/webrick/server.rb10
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/webrick/config.rb b/lib/webrick/config.rb
index 10db6e094..121669c13 100644
--- a/lib/webrick/config.rb
+++ b/lib/webrick/config.rb
@@ -34,6 +34,7 @@ module WEBrick
:StopCallback => nil,
:AcceptCallback => nil,
:DoNotReverseLookup => nil,
+ :ShutdownSocketWithoutClose => false,
}
# for HTTPServer, HTTPRequest, HTTPResponse ...
diff --git a/lib/webrick/server.rb b/lib/webrick/server.rb
index 3adbded5f..54375d2e7 100644
--- a/lib/webrick/server.rb
+++ b/lib/webrick/server.rb
@@ -129,7 +129,10 @@ module WEBrick
addr = s.addr
@logger.debug("close TCPSocket(#{addr[2]}, #{addr[1]})")
end
- s.close
+ s.shutdown
+ unless @config[:ShutdownSocketWithoutClose]
+ s.close
+ end
}
@listeners.clear
end
@@ -147,9 +150,8 @@ module WEBrick
sock.sync = true
Utils::set_non_blocking(sock)
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 Errno::ECONNRESET, Errno::ECONNABORTED,
+ Errno::EPROTO, Errno::EINVAL => ex
rescue Exception => ex
msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
@logger.error msg