summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-14 22:59:09 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-14 22:59:09 +0000
commit8db529ca2bc2f718ed2b0179ae489342b0d8f01a (patch)
tree41798feecdd950003372dedac78277b97e8dba90
parentad46d47e6ab48d3a19457bd613d2fd8ff84f9a0e (diff)
* lib/webrick/server.rb (WEBrick::GenericServer#accept_client):
sockets should be non-blocking mode. [ruby-dev:26405] * lib/webrick/utils.rb (WEBrick::Utils.set_non_blocking): new method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--lib/webrick/server.rb1
-rw-r--r--lib/webrick/utils.rb8
3 files changed, 16 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 44a88ed10c..a872dd8ad5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Jul 15 07:58:10 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * lib/webrick/server.rb (WEBrick::GenericServer#accept_client):
+ sockets should be non-blocking mode. [ruby-dev:26405]
+
+ * lib/webrick/utils.rb (WEBrick::Utils.set_non_blocking): new method.
+
Thu Jul 15 00:11:36 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enum.c (enumeratorize): create new enumerator for current method if
diff --git a/lib/webrick/server.rb b/lib/webrick/server.rb
index 46575734c1..5e57966255 100644
--- a/lib/webrick/server.rb
+++ b/lib/webrick/server.rb
@@ -146,6 +146,7 @@ module WEBrick
begin
sock = svr.accept
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
diff --git a/lib/webrick/utils.rb b/lib/webrick/utils.rb
index 7283704c1d..cf9da6f2ce 100644
--- a/lib/webrick/utils.rb
+++ b/lib/webrick/utils.rb
@@ -18,6 +18,14 @@ end
module WEBrick
module Utils
+ def set_non_blocking(io)
+ flag = File::NONBLOCK
+ if defined?(Fcntl::F_GETFL)
+ flag |= io.fcntl(Fcntl::F_GETFL)
+ end
+ io.fcntl(Fcntl::F_SETFL, flag)
+ end
+ module_function :set_non_blocking
def set_close_on_exec(io)
if defined?(Fcntl::FD_CLOEXEC)