about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/unicorn.rb13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 13c203a..681b7d9 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -341,16 +341,13 @@ module Unicorn
     # Terminates all workers, but does not exit master process
     def stop(graceful = true)
       self.listeners = []
-      kill_each_worker(graceful ? :QUIT : :TERM)
-      timeleft = timeout
-      step = 0.2
-      reap_all_workers
-      until WORKERS.empty?
-        sleep(step)
+      limit = Time.now + timeout
+      until WORKERS.empty? || Time.now > limit
+        kill_each_worker(graceful ? :QUIT : :TERM)
+        sleep(0.1)
         reap_all_workers
-        (timeleft -= step) > 0 and next
-        kill_each_worker(:KILL)
       end
+      kill_each_worker(:KILL)
     end
 
     private