From 98255466617c9e0684c72fee10dbba35e950c7ab Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 5 Nov 2007 18:34:00 +0000 Subject: [PATCH] Handle X31 response code from server --- citadel/sendcommand.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/citadel/sendcommand.c b/citadel/sendcommand.c index 9b331cc24..c0709ec57 100644 --- a/citadel/sendcommand.c +++ b/citadel/sendcommand.c @@ -177,6 +177,7 @@ int main(int argc, char **argv) fd_set read_fd; struct timeval tv; int ret, err; + int server_shutting_down = 0; CtdlInitBase64Table(); @@ -232,6 +233,10 @@ int main(int argc, char **argv) tv.tv_sec = 0; tv.tv_usec = 1000; + if (!strncasecmp(&buf[1], "31", 2)) { + server_shutting_down = 1; + } + if (buf[0] == '1') { while (CtdlIPC_chat_recv(ipc, buf), strcmp(buf, "000")) { printf("%s\n", buf); @@ -282,9 +287,16 @@ int main(int argc, char **argv) } alarm(0); /* Shutdown the watchdog timer */ fprintf(stderr, "sendcommand: processing ended.\n"); - if (strcasecmp(cmd, "DOWN")) - cleanup(0); - else /* If we downed the server we can't to do CtdlIPCQuit in cleanup()*/ + + /* Clean up and log off ... unless the server indicated that the command + * we sent is shutting it down, in which case we want to just cut the + * connection and exit. + */ + if (server_shutting_down) { nq_cleanup(0); + } + else { + cleanup(0); + } return 0; } -- 2.39.2