mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 17:57:59 +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"""
|
"""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
|
class RepositoryServer: # pragma: no cover
|
||||||
rpc_methods = (
|
rpc_methods = (
|
||||||
'__len__',
|
'__len__',
|
||||||
|
@ -79,13 +87,18 @@ def serve(self):
|
||||||
if r:
|
if r:
|
||||||
data = os.read(stdin_fd, BUFSIZE)
|
data = os.read(stdin_fd, BUFSIZE)
|
||||||
if not data:
|
if not data:
|
||||||
|
if self.repository is not None:
|
||||||
self.repository.close()
|
self.repository.close()
|
||||||
|
else:
|
||||||
|
os.write(stderr_fd, "Borg {}: Got connection close before repository was opened.\n"
|
||||||
|
.format(__version__).encode())
|
||||||
return
|
return
|
||||||
unpacker.feed(data)
|
unpacker.feed(data)
|
||||||
for unpacked in unpacker:
|
for unpacked in unpacker:
|
||||||
if not (isinstance(unpacked, tuple) and len(unpacked) == 4):
|
if not (isinstance(unpacked, tuple) and len(unpacked) == 4):
|
||||||
|
if self.repository is not None:
|
||||||
self.repository.close()
|
self.repository.close()
|
||||||
raise Exception("Unexpected RPC data format.")
|
raise UnexpectedRPCDataFormatFromClient(__version__)
|
||||||
type, msgid, method, args = unpacked
|
type, msgid, method, args = unpacked
|
||||||
method = method.decode('ascii')
|
method = method.decode('ascii')
|
||||||
try:
|
try:
|
||||||
|
@ -326,7 +339,7 @@ def handle_error(error, res):
|
||||||
self.unpacker.feed(data)
|
self.unpacker.feed(data)
|
||||||
for unpacked in self.unpacker:
|
for unpacked in self.unpacker:
|
||||||
if not (isinstance(unpacked, tuple) and len(unpacked) == 4):
|
if not (isinstance(unpacked, tuple) and len(unpacked) == 4):
|
||||||
raise Exception("Unexpected RPC data format.")
|
raise UnexpectedRPCDataFormatFromServer()
|
||||||
type, msgid, error, res = unpacked
|
type, msgid, error, res = unpacked
|
||||||
if msgid in self.ignore_responses:
|
if msgid in self.ignore_responses:
|
||||||
self.ignore_responses.remove(msgid)
|
self.ignore_responses.remove(msgid)
|
||||||
|
|
Loading…
Reference in a new issue