mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-07 23:18:43 +00:00
Merge pull request #1095 from Voltara/master
RemoteRepository: Fix busy wait in call_many, fixes #940
This commit is contained in:
commit
1ec149fe27
1 changed files with 7 additions and 4 deletions
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
BUFSIZE = 10 * 1024 * 1024
|
BUFSIZE = 10 * 1024 * 1024
|
||||||
|
|
||||||
|
MAX_INFLIGHT = 100
|
||||||
|
|
||||||
|
|
||||||
class ConnectionClosed(Error):
|
class ConnectionClosed(Error):
|
||||||
"""Connection closed by remote host"""
|
"""Connection closed by remote host"""
|
||||||
|
@ -246,7 +248,6 @@ def fetch_from_cache(args):
|
||||||
|
|
||||||
calls = list(calls)
|
calls = list(calls)
|
||||||
waiting_for = []
|
waiting_for = []
|
||||||
w_fds = [self.stdin_fd]
|
|
||||||
while wait or calls:
|
while wait or calls:
|
||||||
while waiting_for:
|
while waiting_for:
|
||||||
try:
|
try:
|
||||||
|
@ -275,6 +276,10 @@ def fetch_from_cache(args):
|
||||||
return
|
return
|
||||||
except KeyError:
|
except KeyError:
|
||||||
break
|
break
|
||||||
|
if self.to_send or ((calls or self.preload_ids) and len(waiting_for) < MAX_INFLIGHT):
|
||||||
|
w_fds = [self.stdin_fd]
|
||||||
|
else:
|
||||||
|
w_fds = []
|
||||||
r, w, x = select.select(self.r_fds, w_fds, self.x_fds, 1)
|
r, w, x = select.select(self.r_fds, w_fds, self.x_fds, 1)
|
||||||
if x:
|
if x:
|
||||||
raise Exception('FD exception occurred')
|
raise Exception('FD exception occurred')
|
||||||
|
@ -311,7 +316,7 @@ def fetch_from_cache(args):
|
||||||
else:
|
else:
|
||||||
sys.stderr.write("Remote: " + line)
|
sys.stderr.write("Remote: " + line)
|
||||||
if w:
|
if w:
|
||||||
while not self.to_send and (calls or self.preload_ids) and len(waiting_for) < 100:
|
while not self.to_send and (calls or self.preload_ids) and len(waiting_for) < MAX_INFLIGHT:
|
||||||
if calls:
|
if calls:
|
||||||
if is_preloaded:
|
if is_preloaded:
|
||||||
if calls[0] in self.cache:
|
if calls[0] in self.cache:
|
||||||
|
@ -338,8 +343,6 @@ def fetch_from_cache(args):
|
||||||
# that the fd should be writable
|
# that the fd should be writable
|
||||||
if e.errno != errno.EAGAIN:
|
if e.errno != errno.EAGAIN:
|
||||||
raise
|
raise
|
||||||
if not self.to_send and not (calls or self.preload_ids):
|
|
||||||
w_fds = []
|
|
||||||
self.ignore_responses |= set(waiting_for)
|
self.ignore_responses |= set(waiting_for)
|
||||||
|
|
||||||
def check(self, repair=False, save_space=False):
|
def check(self, repair=False, save_space=False):
|
||||||
|
|
Loading…
Reference in a new issue