From c2e69a3696893b15100c2eb8fe3404e40e4b16a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Wed, 30 Oct 2013 15:02:16 -0300 Subject: Return port and factory from the imap launch method --- mail/changes/bug_return_factory_and_port_imap | 2 ++ mail/src/leap/mail/imap/service/imap.py | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 mail/changes/bug_return_factory_and_port_imap (limited to 'mail') diff --git a/mail/changes/bug_return_factory_and_port_imap b/mail/changes/bug_return_factory_and_port_imap new file mode 100644 index 00000000..75f96d7b --- /dev/null +++ b/mail/changes/bug_return_factory_and_port_imap @@ -0,0 +1,2 @@ + o Return the necessary references (factory, port) from IMAP4 launch + in order to be able to properly stop it. Related to #4199. \ No newline at end of file diff --git a/mail/src/leap/mail/imap/service/imap.py b/mail/src/leap/mail/imap/service/imap.py index b840e864..b641d2eb 100644 --- a/mail/src/leap/mail/imap/service/imap.py +++ b/mail/src/leap/mail/imap/service/imap.py @@ -141,7 +141,9 @@ def run_service(*args, **kwargs): Main entry point to run the service from the client. :returns: the LoopingCall instance that will have to be stoppped - before shutting down the client. + before shutting down the client, the port as returned by + the reactor when starts listening, and the factory for + the protocol. """ leap_assert(len(args) == 2) soledad, keymanager = args @@ -157,8 +159,8 @@ def run_service(*args, **kwargs): from twisted.internet import reactor try: - reactor.listenTCP(port, factory, - interface="localhost") + tport = reactor.listenTCP(port, factory, + interface="localhost") fetcher = LeapIncomingMail( keymanager, soledad, @@ -174,7 +176,7 @@ def run_service(*args, **kwargs): fetcher.start_loop() logger.debug("IMAP4 Server is RUNNING in port %s" % (port,)) leap_events.signal(IMAP_SERVICE_STARTED, str(port)) - return fetcher + return fetcher, tport, factory # not ok, signal error. leap_events.signal(IMAP_SERVICE_FAILED_TO_START, str(port)) -- cgit v1.2.3