From 6089bda52edd16ce343e3e29718418f2852e76af Mon Sep 17 00:00:00 2001 From: Evan Weaver Date: Sat, 31 Jan 2009 14:48:25 -0800 Subject: Make stop raise if server was not started. --- lib/mongrel.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3-24-ge0c7