about summary refs log tree commit homepage
path: root/lib/rainbows/xepoll_thread_spawn
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-05-20 09:19:51 +0000
committerEric Wong <normalperson@yhbt.net>2011-05-20 09:21:18 +0000
commitea6d0eab436c78113f8a61e7fcc34db4117d14c0 (patch)
treed70b0bd67e444997f4122c246ce438dc449242ce /lib/rainbows/xepoll_thread_spawn
parent90af18f6884857704d72fd6b2bb91718aad72117 (diff)
downloadrainbows-ea6d0eab436c78113f8a61e7fcc34db4117d14c0.tar.gz
In concurrency models long keepalive times are cheap (and thus
more likely to be used), this allows Rainbows! to gracefully
shut down more quickly.
Diffstat (limited to 'lib/rainbows/xepoll_thread_spawn')
-rw-r--r--lib/rainbows/xepoll_thread_spawn/client.rb6
1 files changed, 5 insertions, 1 deletions
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