mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-01 12:45:34 +00:00
borg serve: shutdown server after sending all queued log records
This commit is contained in:
parent
746cef1cba
commit
ac4b5c35da
1 changed files with 11 additions and 5 deletions
|
@ -157,6 +157,7 @@ def serve(self):
|
|||
os.set_blocking(stdin_fd, False)
|
||||
os.set_blocking(stdout_fd, True)
|
||||
unpacker = get_limited_unpacker("server")
|
||||
shutdown_serve = False
|
||||
while True:
|
||||
# before processing any new RPCs, send out all pending log output
|
||||
while True:
|
||||
|
@ -169,14 +170,19 @@ def serve(self):
|
|||
msg = msgpack.packb({LOG: lr_dict})
|
||||
os_write(stdout_fd, msg)
|
||||
|
||||
if shutdown_serve:
|
||||
# shutdown wanted! get out of here after sending all log output.
|
||||
if self.repository is not None:
|
||||
self.repository.close()
|
||||
return
|
||||
|
||||
# process new RPCs
|
||||
r, w, es = select.select([stdin_fd], [], [], 10)
|
||||
if r:
|
||||
data = os.read(stdin_fd, BUFSIZE)
|
||||
if not data:
|
||||
if self.repository is not None:
|
||||
self.repository.close()
|
||||
return
|
||||
shutdown_serve = True
|
||||
continue
|
||||
unpacker.feed(data)
|
||||
for unpacked in unpacker:
|
||||
if isinstance(unpacked, dict):
|
||||
|
@ -241,8 +247,8 @@ def serve(self):
|
|||
else:
|
||||
os_write(stdout_fd, msgpack.packb({MSGID: msgid, RESULT: res}))
|
||||
if es:
|
||||
self.repository.close()
|
||||
return
|
||||
shutdown_serve = True
|
||||
continue
|
||||
|
||||
def negotiate(self, client_data):
|
||||
if isinstance(client_data, dict):
|
||||
|
|
Loading…
Reference in a new issue