diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-08-17 18:00:19 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-08-17 18:00:19 +0100 |
commit | 992aec20269d7154016b71edf6b01e02be3328ca (patch) | |
tree | b3b99cf18bb8d85a478f6531f7f87220bedd58c3 /lib | |
parent | ca0a64f05616d80894e3d28c8158a624edd4eb8d (diff) |
Tidied up disconnections
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mauve/pop3_server.rb | 21 |
1 files changed, 19 insertions, 2 deletions
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 |