about summary refs log tree commit homepage
path: root/lib/rainbows/base.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-09-28 17:40:01 -0700
committerEric Wong <normalperson@yhbt.net>2010-09-28 17:40:01 -0700
commitad821f70a2488a91f2be1ac53cb2e64f50743989 (patch)
tree6db4d334106360305ba3b66b643e8694f232fa10 /lib/rainbows/base.rb
parent11c75ec06ce72cea0c760161dc01a196500aa293 (diff)
downloadrainbows-ad821f70a2488a91f2be1ac53cb2e64f50743989.tar.gz
It removes the burden of byte slicing and setting file
descriptor flags.  In some cases, we can remove unnecessary
peeraddr calls, too.
Diffstat (limited to 'lib/rainbows/base.rb')
-rw-r--r--lib/rainbows/base.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/rainbows/base.rb b/lib/rainbows/base.rb
index 2f4d379..59747c7 100644
--- a/lib/rainbows/base.rb
+++ b/lib/rainbows/base.rb
@@ -24,10 +24,19 @@ module Rainbows::Base
     Rainbows::MaxBody.setup
     G.tmp = worker.tmp
 
-    # avoid spurious wakeups and blocking-accept() with 1.8 green threads
-    if ! defined?(RUBY_ENGINE) && RUBY_VERSION.to_f < 1.9
-      require "io/nonblock"
-      Rainbows::HttpServer::LISTENERS.each { |l| l.nonblock = true }
+    listeners = Rainbows::HttpServer::LISTENERS
+    Rainbows::HttpServer::IO_PURGATORY.concat(listeners)
+
+    # no need for this when Unicorn uses Kgio
+    listeners.map! do |io|
+      case io
+      when TCPServer
+        Kgio::TCPServer.for_fd(io.fileno)
+      when UNIXServer
+        Kgio::UNIXServer.for_fd(io.fileno)
+      else
+        io
+      end
     end
 
     # we're don't use the self-pipe mechanism in the Rainbows! worker