mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 01:37:20 +00:00
Merge pull request #1525 from textshell/fix/remote-manual-ssh
borg serve throws exception while trying to close when it gets eof at start
This commit is contained in:
commit
17bd6e0ef4
1 changed files with 17 additions and 4 deletions
|
@ -37,6 +37,14 @@ class InvalidRPCMethod(Error):
|
|||
"""RPC method {} is not valid"""
|
||||
|
||||
|
||||
class UnexpectedRPCDataFormatFromClient(Error):
|
||||
"""Borg {}: Got unexpected RPC data format from client."""
|
||||
|
||||
|
||||
class UnexpectedRPCDataFormatFromServer(Error):
|
||||
"""Got unexpected RPC data format from server."""
|
||||
|
||||
|
||||
class RepositoryServer: # pragma: no cover
|
||||
rpc_methods = (
|
||||
'__len__',
|
||||
|
@ -79,13 +87,18 @@ def serve(self):
|
|||
if r:
|
||||
data = os.read(stdin_fd, BUFSIZE)
|
||||
if not data:
|
||||
if self.repository is not None:
|
||||
self.repository.close()
|
||||
else:
|
||||
os.write(stderr_fd, "Borg {}: Got connection close before repository was opened.\n"
|
||||
.format(__version__).encode())
|
||||
return
|
||||
unpacker.feed(data)
|
||||
for unpacked in unpacker:
|
||||
if not (isinstance(unpacked, tuple) and len(unpacked) == 4):
|
||||
if self.repository is not None:
|
||||
self.repository.close()
|
||||
raise Exception("Unexpected RPC data format.")
|
||||
raise UnexpectedRPCDataFormatFromClient(__version__)
|
||||
type, msgid, method, args = unpacked
|
||||
method = method.decode('ascii')
|
||||
try:
|
||||
|
@ -326,7 +339,7 @@ def handle_error(error, res):
|
|||
self.unpacker.feed(data)
|
||||
for unpacked in self.unpacker:
|
||||
if not (isinstance(unpacked, tuple) and len(unpacked) == 4):
|
||||
raise Exception("Unexpected RPC data format.")
|
||||
raise UnexpectedRPCDataFormatFromServer()
|
||||
type, msgid, error, res = unpacked
|
||||
if msgid in self.ignore_responses:
|
||||
self.ignore_responses.remove(msgid)
|
||||
|
|
Loading…
Reference in a new issue