HUGE PATCH. This moves all of mime_parser.c and all
[citadel.git] / citadel / ipc_c_tcp.c
index 1e8e8dcb44a3477573b3968a3d0019c28a38ed4a..bc68721c6aa9e768199ef70027fe8dce2843abe3 100644 (file)
 #include <pwd.h>
 #include <errno.h>
 #include <stdarg.h>
+#include <libcitadel.h>
 #include "citadel.h"
 #include "citadel_ipc.h"
 #include "citadel_decls.h"
-#include "tools.h"
 #ifndef HAVE_SNPRINTF
 #include "snprintf.h"
 #endif
@@ -47,21 +47,33 @@ void setIPCErrorPrintf(int (*func)(char *s, ...)) {
        error_printf = func;
 }
 
-void connection_died(CtdlIPC *ipc) {
+void connection_died(CtdlIPC* ipc, int using_ssl) {
        if (deathHook != NULL)
                deathHook();
 
-       error_printf("\rYour connection to this Citadel server is broken.\n"
-                       "Last error: %s\n"
-                       "Please re-connect and log in again.\n",
-                       strerror(errno));
+       error_printf("\r\nYour 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()));
+       } else
+#endif
+               error_printf("Last error: %s\n", strerror(errno));
+
+       error_printf("Please re-connect and log in again.\n");
+       fflush(stderr);
+       fflush(stdout);
+
 #ifdef HAVE_OPENSSL
-       SSL_shutdown(ipc->ssl);
        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);
 }