1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-24 08:45:13 +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.callbacks = {}
self.msgid = 0 self.msgid = 0
self.recursion = 0 self.recursion = 0
self.odata = '' self.odata = []
self.id, self.tid = self.cmd('open', (location.path, create)) self.id, self.tid = self.cmd('open', (location.path, create))
def wait(self, write=True): def wait(self, write=True):
@ -122,7 +122,7 @@ def wait(self, write=True):
def cmd(self, cmd, args, callback=None, callback_data=None): def cmd(self, cmd, args, callback=None, callback_data=None):
self.msgid += 1 self.msgid += 1
self.notifier.enabled.inc() 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 self.recursion += 1
if callback: if callback:
self.callbacks[self.msgid] = callback, callback_data 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() self.notifier.enabled.dec()
if msgid == self.msgid: if msgid == self.msgid:
if error: if error:
self.recursion -= 1
raise self.RPCError(error) raise self.RPCError(error)
self.recursion -= 1 self.recursion -= 1
return res return res
@ -149,9 +150,10 @@ def cmd(self, cmd, args, callback=None, callback_data=None):
if c: if c:
c(res, error, d) c(res, error, d)
elif self.odata and self.channel.send_ready(): elif self.odata and self.channel.send_ready():
n = self.channel.send(self.odata) data = self.odata.pop(0)
if n > 0: n = self.channel.send(data)
self.odata = self.odata[n:] if n != len(data):
self.odata.insert(0, data[n:])
if not self.odata and callback: if not self.odata and callback:
self.recursion -= 1 self.recursion -= 1
return return