From ba9a22b6926db058199d44a626b923376c8a850f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 4 Feb 2011 22:38:31 +0000 Subject: epoll: handle EINTR properly in Ruby-space We can't work around it effectively in the C extension itself. This requires the latest sleepy_penguin gem. --- lib/rainbows/epoll.rb | 6 ------ lib/rainbows/epoll/server.rb | 1 + lib/rainbows/xaccept_epoll.rb | 1 - lib/rainbows/xaccept_epoll/client.rb | 1 + t/test_isolate.rb | 2 +- 5 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/rainbows/epoll.rb b/lib/rainbows/epoll.rb index 54d08fb..c8c013e 100644 --- a/lib/rainbows/epoll.rb +++ b/lib/rainbows/epoll.rb @@ -12,15 +12,9 @@ module Rainbows::Epoll autoload :ResponsePipe, 'rainbows/epoll/response_pipe' autoload :ResponseChunkPipe, 'rainbows/epoll/response_chunk_pipe' - def self.quit! - Rainbows.quit! - EP.close unless EP.closed? - end - def init_worker_process(worker) super Rainbows::Epoll.const_set :EP, SleepyPenguin::Epoll.new - trap(:QUIT) { Rainbows::Epoll.quit! } Rainbows::Client.__send__ :include, Client end diff --git a/lib/rainbows/epoll/server.rb b/lib/rainbows/epoll/server.rb index 53b87ab..820a6da 100644 --- a/lib/rainbows/epoll/server.rb +++ b/lib/rainbows/epoll/server.rb @@ -17,6 +17,7 @@ module Rainbows::Epoll::Server obj.epoll_run end Rainbows::Epoll::Client.expire + rescue Errno::EINTR rescue => e Rainbows::Error.listen_loop(e) end while Rainbows.tick || @@nr > 0 diff --git a/lib/rainbows/xaccept_epoll.rb b/lib/rainbows/xaccept_epoll.rb index 0690c07..94ad332 100644 --- a/lib/rainbows/xaccept_epoll.rb +++ b/lib/rainbows/xaccept_epoll.rb @@ -14,7 +14,6 @@ module Rainbows::XAcceptEpoll def init_worker_process(worker) super Rainbows::Epoll.const_set :EP, SleepyPenguin::Epoll.new - trap(:QUIT) { Rainbows::Epoll.quit! } Rainbows::Client.__send__ :include, Client end diff --git a/lib/rainbows/xaccept_epoll/client.rb b/lib/rainbows/xaccept_epoll/client.rb index 6c3a0f5..f0fecd0 100644 --- a/lib/rainbows/xaccept_epoll/client.rb +++ b/lib/rainbows/xaccept_epoll/client.rb @@ -28,6 +28,7 @@ module Rainbows::XAcceptEpoll::Client begin EP.wait(nil, @timeout) { |flags, obj| obj.epoll_run } Rainbows::Epoll::Client.expire + rescue Errno::EINTR rescue => e Rainbows::Error.listen_loop(e) end while Rainbows.tick diff --git a/t/test_isolate.rb b/t/test_isolate.rb index f9b9d84..b1f6fe6 100644 --- a/t/test_isolate.rb +++ b/t/test_isolate.rb @@ -35,7 +35,7 @@ Isolate.now!(opts) do gem 'rack-fiber_pool', '0.9.1' end - gem 'sleepy_penguin', '1.3.1' if RUBY_PLATFORM =~ /linux/ + gem 'sleepy_penguin', '1.4.0' if RUBY_PLATFORM =~ /linux/ end $stdout.reopen(old_out) -- cgit v1.2.3-24-ge0c7