From 98f99d1106a8941b701acda78095c3e4d1cd5f9e Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 14 Sep 2015 15:33:01 -0300 Subject: [bug] review some of the close methods We are getting "too many files open" while running tests with 1024 max files open. This is a leak from close methods. Some of them should be fixed on this commit, but further investigation may be necessary. --- client/src/leap/soledad/client/encdecpool.py | 2 ++ client/src/leap/soledad/client/http_target/api.py | 7 ++++++- client/src/leap/soledad/client/sqlcipher.py | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/client/src/leap/soledad/client/encdecpool.py b/client/src/leap/soledad/client/encdecpool.py index 2ad98767..6d3c11b9 100644 --- a/client/src/leap/soledad/client/encdecpool.py +++ b/client/src/leap/soledad/client/encdecpool.py @@ -74,6 +74,8 @@ class SyncEncryptDecryptPool(object): self._started = True def stop(self): + if not self._started: + return self._started = False self._destroy_pool() # maybe cancel the next delayed call diff --git a/client/src/leap/soledad/client/http_target/api.py b/client/src/leap/soledad/client/http_target/api.py index dc13e9cc..dcc762f6 100644 --- a/client/src/leap/soledad/client/http_target/api.py +++ b/client/src/leap/soledad/client/http_target/api.py @@ -32,8 +32,13 @@ class SyncTargetAPI(SyncTarget): Declares public methods and implements u1db.SyncTarget. """ + @defer.inlineCallbacks def close(self): - self._http.close() + if self._sync_enc_pool: + self._sync_enc_pool.stop() + if self._sync_decr_pool: + self._sync_decr_pool.stop() + yield self._http.close() def set_creds(self, creds): """ diff --git a/client/src/leap/soledad/client/sqlcipher.py b/client/src/leap/soledad/client/sqlcipher.py index 2151884a..22ddc87d 100644 --- a/client/src/leap/soledad/client/sqlcipher.py +++ b/client/src/leap/soledad/client/sqlcipher.py @@ -559,6 +559,7 @@ class SQLCipherU1DBSync(SQLCipherDatabase): """ Close the syncer and syncdb orderly """ + super(SQLCipherU1DBSync, self).close() # close all open syncers for url in self._syncers.keys(): _, syncer = self._syncers[url] -- cgit v1.2.3