#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
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);
}