about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-07-04 07:40:58 +0000
committerEric Wong <normalperson@yhbt.net>2010-07-04 07:44:47 +0000
commite867a6d1a612baf7975b14f9bffa14ea8b05f35c (patch)
treedaa1c2060286c7ae22232ee3ee2d2e472ed7f8d1
parent7e3de7a12629423e911dae8955e7cc2035d6c401 (diff)
downloadrainbows-e867a6d1a612baf7975b14f9bffa14ea8b05f35c.tar.gz
We may use a blocking accept() loop if there is
only a single listener.  In that case threads may
not be able to exit if a SIGQUIT is received, so
force them to run when joining.
-rw-r--r--lib/rainbows/thread_pool.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/rainbows/thread_pool.rb b/lib/rainbows/thread_pool.rb
index 6fce3c1..f609483 100644
--- a/lib/rainbows/thread_pool.rb
+++ b/lib/rainbows/thread_pool.rb
@@ -70,7 +70,12 @@ module Rainbows
       G.quit!
       threads.delete_if do |thr|
         G.tick
-        thr.alive? ? thr.join(0.01) : true
+        begin
+          thr.run
+          thr.join(0.01)
+        rescue
+          true
+        end
       end until threads.empty?
     end