From: Sebastian Harl Date: Thu, 6 Feb 2014 19:11:45 +0000 (+0100) Subject: sysdb: Handle EOF from the server. X-Git-Tag: sysdb-0.1.0~216 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=840ccffd2fbeb0277b1637941f396ce023dcec3d;p=sysdb.git sysdb: Handle EOF from the server. --- 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");