From 992aec20269d7154016b71edf6b01e02be3328ca Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Wed, 17 Aug 2011 18:00:19 +0100 Subject: Tidied up disconnections --- lib/mauve/pop3_server.rb | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/mauve/pop3_server.rb b/lib/mauve/pop3_server.rb index f4dbf3a..645fe0d 100644 --- a/lib/mauve/pop3_server.rb +++ b/lib/mauve/pop3_server.rb @@ -41,17 +41,26 @@ module Mauve unless @server and @server.running? @server = Mauve::Pop3Backend.new(@ip.to_s, @port) logger.info "Listening on #{@server.to_s}" + # + # The next statment doesn't return. + # @server.start end end def stop - @server.stop if @server and @server.running? + if @server.running? + @server.stop + else + @server.stop! + end + super end def join - @server.stop! if @server and @server.running? + @server.stop! if @server + super end @@ -68,6 +77,14 @@ module Mauve @signature = EventMachine.start_server(@host, @port, Pop3Connection) end + def disconnect + # + # Only do this if EventMachine is still going.. The http_server may have + # stopped it already. + # + EventMachine.stop_server(@signature) if EventMachine.reactor_running? + end + end -- cgit v1.2.1