From ea6d0eab436c78113f8a61e7fcc34db4117d14c0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 20 May 2011 09:19:51 +0000 Subject: coolio* + *epoll*: drop keepalive clients on SIGQUIT In concurrency models long keepalive times are cheap (and thus more likely to be used), this allows Rainbows! to gracefully shut down more quickly. --- lib/rainbows/xepoll_thread_spawn/client.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/rainbows/xepoll_thread_spawn') diff --git a/lib/rainbows/xepoll_thread_spawn/client.rb b/lib/rainbows/xepoll_thread_spawn/client.rb index 2ab64d2..c6f2301 100644 --- a/lib/rainbows/xepoll_thread_spawn/client.rb +++ b/lib/rainbows/xepoll_thread_spawn/client.rb @@ -26,11 +26,15 @@ module Rainbows::XEpollThreadSpawn::Client ep = SleepyPenguin::Epoll EP = ep.new - Rainbows.at_quit { EP.close } IN = ep::IN | ep::ET | ep::ONESHOT KATO = {} KATO.compare_by_identity if KATO.respond_to?(:compare_by_identity) LOCK = Mutex.new + Rainbows.at_quit do + clients = nil + LOCK.synchronize { clients = KATO.keys; KATO.clear } + clients.each { |io| io.closed? or io.close } + end @@last_expire = Time.now def kato_set -- cgit v1.2.3-24-ge0c7