summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/changes_feature_4452_defer_initial_sync1
-rw-r--r--src/leap/bitmask/services/mail/conductor.py2
-rw-r--r--src/leap/bitmask/services/soledad/soledadbootstrapper.py20
3 files changed, 16 insertions, 7 deletions
diff --git a/changes/changes_feature_4452_defer_initial_sync b/changes/changes_feature_4452_defer_initial_sync
new file mode 100644
index 00000000..44e1d2d2
--- /dev/null
+++ b/changes/changes_feature_4452_defer_initial_sync
@@ -0,0 +1 @@
+- Do not wait for initial soledad sync to complete to launch mail services. Closes: #4452
diff --git a/src/leap/bitmask/services/mail/conductor.py b/src/leap/bitmask/services/mail/conductor.py
index a9621b13..addf9bef 100644
--- a/src/leap/bitmask/services/mail/conductor.py
+++ b/src/leap/bitmask/services/mail/conductor.py
@@ -98,6 +98,7 @@ class IMAPControl(object):
logger.debug('Stopping imap service.')
# Stop the loop call in the fetcher
self.imap_service.stop()
+ self.imap_service = None
# Stop listening on the IMAP port
self.imap_port.stopListening()
# Stop the protocol
@@ -107,7 +108,6 @@ class IMAPControl(object):
"""
Fetches incoming mail.
"""
- # TODO have a mutex over fetch operation.
if self.imap_service:
logger.debug('Client connected, fetching mail...')
self.imap_service.fetch()
diff --git a/src/leap/bitmask/services/soledad/soledadbootstrapper.py b/src/leap/bitmask/services/soledad/soledadbootstrapper.py
index ce8bf813..70318ab8 100644
--- a/src/leap/bitmask/services/soledad/soledadbootstrapper.py
+++ b/src/leap/bitmask/services/soledad/soledadbootstrapper.py
@@ -28,6 +28,8 @@ from PySide import QtCore
from u1db import errors as u1db_errors
from zope.proxy import sameProxiedObjects
+from twisted.internet.threads import deferToThread
+
from leap.bitmask.config import flags
from leap.bitmask.config.providerconfig import ProviderConfig
from leap.bitmask.crypto.srpauth import SRPAuth
@@ -194,16 +196,17 @@ class SoledadBootstrapper(AbstractBootstrapper):
leap_assert(not sameProxiedObjects(self._soledad, None),
"Null soledad, error while initializing")
+ self.deferred = deferToThread(self._do_soledad_sync)
+ def _do_soledad_sync(self):
+ """
+ Does several retries to get an initial soledad sync.
+ """
# and now, let's sync
sync_tries = self.MAX_SYNC_RETRIES
while sync_tries > 0:
try:
self._try_soledad_sync()
-
- # at this point, sometimes the client
- # gets stuck and does not progress to
- # the _gen_key step. XXX investigate.
logger.debug("Soledad has been synced.")
# so long, and thanks for all the fish
return
@@ -259,26 +262,32 @@ class SoledadBootstrapper(AbstractBootstrapper):
except socket.timeout:
logger.debug("SOLEDAD initialization TIMED OUT...")
self.soledad_timeout.emit()
+ raise
except socket.error as exc:
logger.warning("Socket error while initializing soledad")
self.soledad_timeout.emit()
+ raise
except BootstrapSequenceError as exc:
logger.warning("Error while initializing soledad")
self.soledad_timeout.emit()
+ raise
# unrecoverable
except u1db_errors.Unauthorized:
logger.error("Error while initializing soledad "
"(unauthorized).")
self.soledad_failed.emit()
+ raise
except u1db_errors.HTTPError as exc:
logger.exception("Error whie initializing soledad "
"(HTTPError)")
self.soledad_failed.emit()
+ raise
except Exception as exc:
logger.exception("Unhandled error while initializating "
"soledad: %r" % (exc,))
self.soledad_failed.emit()
+ raise
def _try_soledad_sync(self):
"""
@@ -292,9 +301,8 @@ class SoledadBootstrapper(AbstractBootstrapper):
logger.error("%r" % (exc,))
raise SoledadSyncError("Failed to sync soledad")
except Exception as exc:
- logger.exception("Unhandled error while syncing"
+ logger.exception("Unhandled error while syncing "
"soledad: %r" % (exc,))
- self.soledad_failed.emit()
raise SoledadSyncError("Failed to sync soledad")
def _download_config(self):