diff options
author | Evan Weaver <eweaver@twitter.com> | 2009-01-31 14:48:25 -0800 |
---|---|---|
committer | Evan Weaver <eweaver@twitter.com> | 2009-01-31 14:48:25 -0800 |
commit | 6089bda52edd16ce343e3e29718418f2852e76af (patch) | |
tree | 52e45c03ad7361a2fbe4ba50283c1af4ede27be4 /lib | |
parent | fbd8d29a966acea44f19596db5a55382b70b51da (diff) | |
download | unicorn-6089bda52edd16ce343e3e29718418f2852e76af.tar.gz |
Diffstat (limited to 'lib')
-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 |