about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEvan Weaver <eweaver@twitter.com>2009-01-31 14:48:25 -0800
committerEvan Weaver <eweaver@twitter.com>2009-01-31 14:48:25 -0800
commit6089bda52edd16ce343e3e29718418f2852e76af (patch)
tree52e45c03ad7361a2fbe4ba50283c1af4ede27be4
parentfbd8d29a966acea44f19596db5a55382b70b51da (diff)
downloadunicorn-6089bda52edd16ce343e3e29718418f2852e76af.tar.gz
-rw-r--r--lib/mongrel.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/mongrel.rb b/lib/mongrel.rb
index 83ee578..00e7624 100644
--- a/lib/mongrel.rb
+++ b/lib/mongrel.rb
@@ -47,6 +47,9 @@ module Mongrel
   # Thrown at a thread when it is timed out.
   class TimeoutError < Exception; end
 
+  # Thrown by HttpServer#stop if the server is not started.
+  class AcceptorError < StandardError; end
+
   # A Hash with one extra parameter for the HTTP body, used internally.
   class HttpParams < Hash
     attr_accessor :http_body
@@ -294,9 +297,11 @@ module Mongrel
 
     # Stops the acceptor thread and then causes the worker threads to finish
     # off the request queue before finally exiting.
-    def stop(synchronous=false)
+    def stop(synchronous = false)
+      raise AcceptorError, "Server was not started." unless @acceptor
       @acceptor.raise(StopServer.new)
       (sleep(0.5) while @acceptor.alive?) if synchronous
+      @acceptor = nil
     end
   end
 end