summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-09-29 13:43:50 -0300
committerTomás Touceda <chiiph@leap.se>2014-09-29 13:43:50 -0300
commite2ca6ff9539e2a0294dd1dc2b76879a1ebeb60ba (patch)
tree0ff727462a387b7a634c2259894dfb1398b968a0
parent509f76c21c7c847dc4111847a3585be7bb67e350 (diff)
parent19f28c432f36022c5f1c0558f4742c864e7202c8 (diff)
Merge remote-tracking branch 'refs/remotes/drebs/bug/5975_fix-transaction-log-order' into develop
-rw-r--r--client/changes/bug_5975_wait-for-last-request-on-sync1
-rw-r--r--client/src/leap/soledad/client/target.py8
-rw-r--r--common/src/leap/soledad/common/couch.py9
3 files changed, 12 insertions, 6 deletions
diff --git a/client/changes/bug_5975_wait-for-last-request-on-sync b/client/changes/bug_5975_wait-for-last-request-on-sync
new file mode 100644
index 00000000..7a394580
--- /dev/null
+++ b/client/changes/bug_5975_wait-for-last-request-on-sync
@@ -0,0 +1 @@
+ o Wait for last post request to finish before starting a new one (#5975).
diff --git a/client/src/leap/soledad/client/target.py b/client/src/leap/soledad/client/target.py
index ae2010a6..651d3ee5 100644
--- a/client/src/leap/soledad/client/target.py
+++ b/client/src/leap/soledad/client/target.py
@@ -1176,6 +1176,7 @@ class SoledadSyncTarget(HTTPSyncTarget, TokenBasedAuth):
synced = []
number_of_docs = len(docs_by_generations)
+ last_request_lock = None
for doc, gen, trans_id in docs_by_generations:
# allow for interrupting the sync process
if self.stopped is True:
@@ -1212,7 +1213,7 @@ class SoledadSyncTarget(HTTPSyncTarget, TokenBasedAuth):
# end of symmetric encryption
# -------------------------------------------------------------
t = syncer_pool.new_syncer_thread(
- sent + 1, total, last_request_lock=None,
+ sent + 1, total, last_request_lock=last_request_lock,
last_callback_lock=last_callback_lock)
# bail out if any thread failed
@@ -1249,7 +1250,12 @@ class SoledadSyncTarget(HTTPSyncTarget, TokenBasedAuth):
# save thread and append
t.start()
threads.append((t, doc))
+
+ # update lock references so they can be used in next call to
+ # syncer_pool.new_syncer_thread() above
last_callback_lock = t.callback_lock
+ last_request_lock = t.request_lock
+
sent += 1
# make sure all threads finished and we have up-to-date info
diff --git a/common/src/leap/soledad/common/couch.py b/common/src/leap/soledad/common/couch.py
index 5658f4ce..a98a8f25 100644
--- a/common/src/leap/soledad/common/couch.py
+++ b/common/src/leap/soledad/common/couch.py
@@ -18,12 +18,12 @@
"""A U1DB backend that uses CouchDB as its persistence layer."""
+
import simplejson as json
import re
import uuid
import logging
import binascii
-import socket
import time
import sys
import threading
@@ -44,7 +44,7 @@ from couchdb.http import (
urljoin as couch_urljoin,
Resource,
)
-from u1db import query_parser, vectorclock
+from u1db import vectorclock
from u1db.errors import (
DatabaseDoesNotExist,
InvalidGeneration,
@@ -60,7 +60,7 @@ from u1db.remote import http_app
from u1db.remote.server_state import ServerState
-from leap.soledad.common import USER_DB_PREFIX, ddocs, errors
+from leap.soledad.common import ddocs, errors
from leap.soledad.common.document import SoledadDocument
@@ -160,7 +160,6 @@ class CouchDocument(SoledadDocument):
"""
if self._conflicts is None:
raise Exception("Run self._ensure_fetch_conflicts first!")
- conflicts_len = len(self._conflicts)
self._conflicts = filter(
lambda doc: doc.rev not in conflict_revs,
self._conflicts)
@@ -1181,7 +1180,7 @@ class CouchDatabase(CommonBackend):
res = self._database.resource(*ddoc_path)
try:
with CouchDatabase.update_handler_lock[self._get_replica_uid()]:
- body={
+ body = {
'other_replica_uid': other_replica_uid,
'other_generation': other_generation,
'other_transaction_id': other_transaction_id,