From 840ccffd2fbeb0277b1637941f396ce023dcec3d Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Thu, 6 Feb 2014 20:11:45 +0100 Subject: [PATCH] sysdb: Handle EOF from the server. --- src/tools/sysdb/command.c | 3 +++ src/tools/sysdb/input.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/tools/sysdb/command.c b/src/tools/sysdb/command.c index 0abf381..1128c38 100644 --- a/src/tools/sysdb/command.c +++ b/src/tools/sysdb/command.c @@ -60,6 +60,9 @@ sdb_command_print_reply(sdb_input_t *input) if (sdb_client_recv(input->client, &rcode, recv_buf) < 0) rcode = UINT32_MAX; + if (sdb_client_eof(input->client)) + return -1; + if (rcode == UINT32_MAX) printf("ERROR: "); result = sdb_strbuf_string(recv_buf); diff --git a/src/tools/sysdb/input.c b/src/tools/sysdb/input.c index f115e3e..3814f0c 100644 --- a/src/tools/sysdb/input.c +++ b/src/tools/sysdb/input.c @@ -47,6 +47,7 @@ #include "tools/sysdb/input.h" #include "tools/sysdb/command.h" +#include "utils/error.h" #include "utils/strbuf.h" #include @@ -178,6 +179,14 @@ input_readline(void) if (! FD_ISSET(client_fd, &fds)) continue; + if (sdb_client_eof(sysdb_input->client)) { + /* XXX: try to reconnect */ + printf("\n"); + sdb_log(SDB_LOG_ERR, "Remote side closed the connection."); + /* return EOF */ + return 0; + } + /* some response / error message from the server pending */ /* XXX: clear current line */ printf("\n"); -- 2.30.2