about summary refs log tree commit homepage
path: root/lib/rainbows/thread_pool.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-10-17 22:42:56 -0700
committerEric Wong <normalperson@yhbt.net>2009-10-17 22:42:56 -0700
commita764983fccd6cce64043d76e09a5e1718e7f8fd6 (patch)
treecd6f730c5b93c584a7cdda57079b318d99bb3120 /lib/rainbows/thread_pool.rb
parent71a1cf90ce16ce6951f1ce76fcea98b13bc54576 (diff)
downloadrainbows-a764983fccd6cce64043d76e09a5e1718e7f8fd6.tar.gz
We use the "G" global constant from the Rev model everywhere
to simplify things a little.
Test cases are more consistent now, too.
Diffstat (limited to 'lib/rainbows/thread_pool.rb')
-rw-r--r--lib/rainbows/thread_pool.rb19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/rainbows/thread_pool.rb b/lib/rainbows/thread_pool.rb
index c742e5d..30e8f69 100644
--- a/lib/rainbows/thread_pool.rb
+++ b/lib/rainbows/thread_pool.rb
@@ -30,7 +30,7 @@ module Rainbows
       pool = (1..worker_connections).map { new_worker_thread }
       m = 0
 
-      while LISTENERS.first && master_pid == Process.ppid
+      while G.alive && master_pid == Process.ppid
         pool.each do |thr|
           worker.tmp.chmod(m = 0 == m ? 1 : 0)
           # if any worker dies, something is serious wrong, bail
@@ -44,21 +44,20 @@ module Rainbows
       Thread.new {
         begin
           begin
-            ret = IO.select(LISTENERS, nil, nil, timeout) or next
-            ret.first.each do |sock|
-              begin
-                process_client(sock.accept_nonblock)
-              rescue Errno::EAGAIN, Errno::ECONNABORTED
-              end
-            end
+            ret = IO.select(LISTENERS, nil, nil, 1) and
+                  ret.first.each do |sock|
+                    begin
+                      process_client(sock.accept_nonblock)
+                    rescue Errno::EAGAIN, Errno::ECONNABORTED
+                    end
+                  end
           rescue Errno::EINTR
-            next
           rescue Errno::EBADF, TypeError
             break
           end
         rescue Object => e
           listen_loop_error(e)
-        end while ! Thread.current[:quit] && LISTENERS.first
+        end while G.alive
       }
     end