about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-10-17 22:42:55 -0700
committerEric Wong <normalperson@yhbt.net>2009-10-17 22:42:55 -0700
commite0c33c583c5b4d2a4661edb6c41d6a60b44dae9d (patch)
tree6c0f7ffb273e2d1b16009e7631323a781797b541
parent031127b1d047d05be7a2ec8af7480d02e9bbdd69 (diff)
downloadrainbows-e0c33c583c5b4d2a4661edb6c41d6a60b44dae9d.tar.gz
I need better tests for graceful shutdown...
-rw-r--r--lib/rainbows/base.rb1
-rw-r--r--lib/rainbows/thread_pool.rb4
-rw-r--r--lib/rainbows/thread_spawn.rb2
3 files changed, 4 insertions, 3 deletions
diff --git a/lib/rainbows/base.rb b/lib/rainbows/base.rb
index f24de31..3f9db96 100644
--- a/lib/rainbows/base.rb
+++ b/lib/rainbows/base.rb
@@ -19,6 +19,7 @@ module Rainbows
 
     # TODO: migrate into Unicorn::HttpServer
     def listen_loop_error(e)
+      return if HttpServer::LISTENERS.first.nil? || IOError === e
       logger.error "Unhandled listen loop exception #{e.inspect}."
       logger.error e.backtrace.join("\n")
     end
diff --git a/lib/rainbows/thread_pool.rb b/lib/rainbows/thread_pool.rb
index d7f0b14..2bae89b 100644
--- a/lib/rainbows/thread_pool.rb
+++ b/lib/rainbows/thread_pool.rb
@@ -55,10 +55,10 @@ module Rainbows
           rescue Errno::EINTR
             next
           rescue Errno::EBADF, TypeError
-            return
+            break
           end
         rescue Object => e
-          listen_loop_error(e) if LISTENERS.first
+          listen_loop_error(e)
         end while ! Thread.current[:quit] && LISTENERS.first
       }
     end
diff --git a/lib/rainbows/thread_spawn.rb b/lib/rainbows/thread_spawn.rb
index d002c81..fb9ea57 100644
--- a/lib/rainbows/thread_spawn.rb
+++ b/lib/rainbows/thread_spawn.rb
@@ -55,7 +55,7 @@ module Rainbows
           end
         end
       rescue Object => e
-        listen_loop_error(e) if LISTENERS.first
+        listen_loop_error(e)
       end while LISTENERS.first && master_pid == Process.ppid
       join_threads(threads.list, worker)
     end