diff options
author | Ruben Pollan <meskio@sindominio.net> | 2015-04-29 00:55:53 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2015-05-21 11:49:58 +0200 |
commit | 9515c944279e08221de1852ab373d24232dccbf1 (patch) | |
tree | b23731dee12f1b3228c60bdf03519d6c1f884749 /src/leap/bitmask/services/soledad | |
parent | 01b005b0642454e3d670089ed7e530eda8e9ef91 (diff) |
[bug] fix soledad bootstrap sync issues
* Instead of checking if soledad is still syncing for the timeuot cancel
the delayed call.
* Count retries properly.
* Now soledad sync only returns SoledadError (#6981).
Diffstat (limited to 'src/leap/bitmask/services/soledad')
-rw-r--r-- | src/leap/bitmask/services/soledad/soledadbootstrapper.py | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/leap/bitmask/services/soledad/soledadbootstrapper.py b/src/leap/bitmask/services/soledad/soledadbootstrapper.py index 6cb4c116..9864e4e1 100644 --- a/src/leap/bitmask/services/soledad/soledadbootstrapper.py +++ b/src/leap/bitmask/services/soledad/soledadbootstrapper.py @@ -22,7 +22,6 @@ import os import socket import sys -from ssl import SSLError from sqlite3 import ProgrammingError as sqlite_ProgrammingError from u1db import errors as u1db_errors @@ -621,14 +620,17 @@ class Syncer(object): # for debugging. self._sync_deferred = self._soledad.sync(defer_decryption=True) self._sync_deferred.addCallbacks(self._success, self._error) - reactor.callLater(self.WAIT_MAX_SECONDS, self._timeout) + self._timeout_delayed_call = reactor.callLater(self.WAIT_MAX_SECONDS, + self._timeout) def _success(self, result): logger.debug("Soledad has been synced!") + self._timeout_delayed_call.cancel() self._callback_deferred.callback(result) # so long, and thanks for all the fish def _error(self, failure): + self._timeout_delayed_call.cancel() if failure.check(InvalidAuthTokenError): logger.error('Invalid auth token while trying to self Soledad') self._signaler.signal( @@ -638,22 +640,11 @@ class Syncer(object): sqlcipher_ProgrammingError): logger.exception("%r" % (failure.value,)) self._callback_deferred.fail(failure) - elif failure.check(SSLError): - logger.error("%r" % (failure.value,)) - self._retry() - elif failure.check(u1db_errors.InvalidGeneration): - logger.error("%r" % (failure.value,)) - self._retry() else: - logger.exception("Unhandled error while syncing " - "soledad: %r" % (failure.value,)) + logger.error("%r" % (failure.value,)) self._retry() def _timeout(self): - if not self._soledad.syncing: - # timeout only if is still syncing - return - # maybe it's my connection, but I'm getting # ssl handshake timeouts and read errors quite often. # A particularly big sync is a disaster. @@ -666,7 +657,7 @@ class Syncer(object): def _retry(self): self._tries += 1 - if self._tries > self.MAX_SYNC_RETRIES: + if self._tries < self.MAX_SYNC_RETRIES: msg = "Sync failed, retrying... (retry {0} of {1})".format( self._tries, self.MAX_SYNC_RETRIES) logger.warning(msg) |