From ad821f70a2488a91f2be1ac53cb2e64f50743989 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 28 Sep 2010 17:40:01 -0700 Subject: start using kgio library It removes the burden of byte slicing and setting file descriptor flags. In some cases, we can remove unnecessary peeraddr calls, too. --- lib/rainbows/base.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lib/rainbows/base.rb') 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 -- cgit v1.2.3-24-ge0c7