From fa45b38b2cf61d5619e8d9d063fb1a470ab4f086 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Fri, 7 Aug 2015 18:34:12 -0300 Subject: [bug] Encdecpool won't explode if stopped twice The encryption pool could be stopped twice and would break on the second attempt because it deletes the encryption queue variable. Added a condition to make sure it only deletes the encryption queue if it exists, making it more idempotent --- client/src/leap/soledad/client/encdecpool.py | 9 +++++---- common/src/leap/soledad/common/tests/test_sync.py | 2 -- common/src/leap/soledad/common/tests/test_sync_deferred.py | 11 ++--------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/client/src/leap/soledad/client/encdecpool.py b/client/src/leap/soledad/client/encdecpool.py index 8713497e..4cdb3cd4 100644 --- a/client/src/leap/soledad/client/encdecpool.py +++ b/client/src/leap/soledad/client/encdecpool.py @@ -191,10 +191,11 @@ class SyncEncrypterPool(SyncEncryptDecryptPool): Stop the encrypter pool. """ # close the sync queue - self._encr_queue.close() - q = self._encr_queue - del q - self._encr_queue = None + if self._encr_queue: + self._encr_queue.close() + q = self._encr_queue + del q + self._encr_queue = None SyncEncryptDecryptPool.stop(self) diff --git a/common/src/leap/soledad/common/tests/test_sync.py b/common/src/leap/soledad/common/tests/test_sync.py index 128b4287..53dd923b 100644 --- a/common/src/leap/soledad/common/tests/test_sync.py +++ b/common/src/leap/soledad/common/tests/test_sync.py @@ -179,8 +179,6 @@ class TestSoledadDbSync( """ Need to explicitely invoke inicialization on all bases. """ - # tests.TestCaseWithServer.setUp(self) - # self.main_test_class = test_sync.TestDbSync SoledadWithCouchServerMixin.setUp(self) self.startServer() self.db = self.make_database_for_test(self, 'test1') diff --git a/common/src/leap/soledad/common/tests/test_sync_deferred.py b/common/src/leap/soledad/common/tests/test_sync_deferred.py index dcbd16f6..126e9b7b 100644 --- a/common/src/leap/soledad/common/tests/test_sync_deferred.py +++ b/common/src/leap/soledad/common/tests/test_sync_deferred.py @@ -34,7 +34,6 @@ from leap.soledad.client.sqlcipher import ( from testscenarios import TestWithScenarios from leap.soledad.common.tests import u1db_tests as tests -from leap.soledad.common.tests.u1db_tests import test_sync from leap.soledad.common.tests.util import ADDRESS from leap.soledad.common.tests.util import SoledadWithCouchServerMixin from leap.soledad.common.tests.util import make_soledad_app @@ -93,10 +92,6 @@ class BaseSoledadDeferredEncTest(SoledadWithCouchServerMixin): ensure_ddocs=True) def tearDown(self): - self.db1.close() - self.db2.close() - self._soledad.close() - # XXX should not access "private" attrs shutil.rmtree(os.path.dirname(self._soledad._local_db_path)) SoledadWithCouchServerMixin.tearDown(self) @@ -112,7 +107,7 @@ class SyncTimeoutError(Exception): class TestSoledadDbSyncDeferredEncDecr( TestWithScenarios, - test_sync.TestDbSync, + tests.TestCaseWithServer, BaseSoledadDeferredEncTest): """ @@ -172,15 +167,13 @@ class TestSoledadDbSyncDeferredEncDecr( self.opts, crypto, replica_uid, + None, defer_encryption=True) self.dbsyncer = dbsyncer return dbsyncer.sync( target_url, creds=creds, - autocreate=True, defer_decryption=DEFER_DECRYPTION) - else: - return test_sync.TestDbSync.do_sync(self, target_name) def wait_for_sync(self): """ -- cgit v1.2.3