diff options
-rw-r--r-- | lib/mongrel.rb | 7 |
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 |