about summary refs log tree commit homepage
path: root/lib/rainbows/xepoll_thread_pool/client.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rainbows/xepoll_thread_pool/client.rb')
-rw-r--r--lib/rainbows/xepoll_thread_pool/client.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/rainbows/xepoll_thread_pool/client.rb b/lib/rainbows/xepoll_thread_pool/client.rb
index b33998d..2cf05e5 100644
--- a/lib/rainbows/xepoll_thread_pool/client.rb
+++ b/lib/rainbows/xepoll_thread_pool/client.rb
@@ -37,11 +37,15 @@ module Rainbows::XEpollThreadPool::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