1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-24 00:37:56 +00:00

Fixed remote store upstream performance issue

This commit is contained in:
Jonas Borgström 2011-08-05 15:52:09 +02:00
parent 64a318501d
commit a4f61d1328

View file

@ -109,7 +109,7 @@ def __init__(self, location, create=False):
self.callbacks = {}
self.msgid = 0
self.recursion = 0
self.odata = ''
self.odata = []
self.id, self.tid = self.cmd('open', (location.path, create))
def wait(self, write=True):
@ -122,7 +122,7 @@ def wait(self, write=True):
def cmd(self, cmd, args, callback=None, callback_data=None):
self.msgid += 1
self.notifier.enabled.inc()
self.odata += msgpack.packb((0, self.msgid, cmd, args))
self.odata.append(msgpack.packb((1, self.msgid, cmd, args)))
self.recursion += 1
if callback:
self.callbacks[self.msgid] = callback, callback_data
@ -141,6 +141,7 @@ def cmd(self, cmd, args, callback=None, callback_data=None):
self.notifier.enabled.dec()
if msgid == self.msgid:
if error:
self.recursion -= 1
raise self.RPCError(error)
self.recursion -= 1
return res
@ -149,9 +150,10 @@ def cmd(self, cmd, args, callback=None, callback_data=None):
if c:
c(res, error, d)
elif self.odata and self.channel.send_ready():
n = self.channel.send(self.odata)
if n > 0:
self.odata = self.odata[n:]
data = self.odata.pop(0)
n = self.channel.send(data)
if n != len(data):
self.odata.insert(0, data[n:])
if not self.odata and callback:
self.recursion -= 1
return