From: Art Cancro Date: Fri, 16 Jan 2009 20:49:12 +0000 (+0000) Subject: * Restore the proper tty parameters when exiting because of a dead server connection. X-Git-Tag: v7.86~1603 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=d7ff277171d5ae8a112ba2236a4dd5b3aefc5f1b;p=citadel.git * Restore the proper tty parameters when exiting because of a dead server connection. --- diff --git a/citadel/getmail.c b/citadel/getmail.c index 104921162..03efd8ba2 100644 --- a/citadel/getmail.c +++ b/citadel/getmail.c @@ -396,3 +396,12 @@ int main(int argc, char **argv) } return 0; } + + +/* + * Stub function + */ +void stty_ctdl(int cmd) { +} + + diff --git a/citadel/ipc_c_tcp.c b/citadel/ipc_c_tcp.c index bc68721c6..787ac3674 100644 --- a/citadel/ipc_c_tcp.c +++ b/citadel/ipc_c_tcp.c @@ -31,10 +31,7 @@ #include "snprintf.h" #endif -/* - * FIXME: rewrite all of Ford's stuff here, it won't work with multiple - * instances - */ +/* Note that some of these functions may not work with multiple instances. */ static void (*deathHook)(void) = NULL; int (*error_printf)(char *s, ...) = (int (*)(char *, ...))printf; @@ -48,39 +45,27 @@ void setIPCErrorPrintf(int (*func)(char *s, ...)) { } void connection_died(CtdlIPC* ipc, int using_ssl) { - if (deathHook != NULL) + if (deathHook != NULL) { deathHook(); + } - error_printf("\r\nYour connection to %s is broken.\n", - ipc->ServInfo.humannode); + stty_ctdl(SB_RESTORE); + fprintf(stderr, "\r\n\n\n"); + fprintf(stderr, "Your connection to %s is broken.\n", ipc->ServInfo.humannode); #ifdef HAVE_OPENSSL if (using_ssl) { - error_printf("Last error: %s\n", - ERR_reason_error_string(ERR_get_error())); + printf(stderr, "Last error: %s\n", ERR_reason_error_string(ERR_get_error())); + SSL_free(ipc->ssl); + ipc->ssl = NULL; } else #endif - error_printf("Last error: %s\n", strerror(errno)); + fprintf(stderr, "Last error: %s\n", strerror(errno)); - error_printf("Please re-connect and log in again.\n"); + fprintf(stderr, "Please re-connect and log in again.\n"); fflush(stderr); fflush(stdout); - -#ifdef HAVE_OPENSSL - SSL_free(ipc->ssl); - ipc->ssl = NULL; -#endif shutdown(ipc->sock, 2); ipc->sock = -1; - printf ("About to exit because of dead socket.\n"); - exit (1); -} - - -/* -static void ipc_timeout(int signum) -{ - error_printf("\rConnection timed out.\n"); - logoff(NULL, 3); + exit(1); } -*/ diff --git a/citadel/sendcommand.c b/citadel/sendcommand.c index 45ff15c5d..2f8a3cfdb 100644 --- a/citadel/sendcommand.c +++ b/citadel/sendcommand.c @@ -305,3 +305,11 @@ int main(int argc, char **argv) } return 0; } + +/* + * Stub function + */ +void stty_ctdl(int cmd) { +} + + diff --git a/citadel/userlist.c b/citadel/userlist.c index 33a0bc85f..3f78cea6f 100644 --- a/citadel/userlist.c +++ b/citadel/userlist.c @@ -105,3 +105,11 @@ char *strerror(int e) return(buf); } #endif + + +/* + * Stub function + */ +void stty_ctdl(int cmd) { +} + diff --git a/citadel/whobbs.c b/citadel/whobbs.c index f4114bb55..e3523aae9 100644 --- a/citadel/whobbs.c +++ b/citadel/whobbs.c @@ -182,6 +182,13 @@ int main(int argc, char **argv) } +/* + * Stub function + */ +void stty_ctdl(int cmd) { +} + + #ifndef HAVE_STRERROR /* * replacement strerror() for systems that don't have it