diff cli-session.c @ 733:70811267715c

Run the cleanup handler also when we close due to TCP connection being closed
author Matt Johnston <matt@ucc.asn.au>
date Mon, 01 Apr 2013 22:26:55 +0800
parents 9a5438271556
children 619b1ed837fd
line wrap: on
line diff
--- a/cli-session.c	Mon Apr 01 22:26:24 2013 +0800
+++ b/cli-session.c	Mon Apr 01 22:26:55 2013 +0800
@@ -42,6 +42,7 @@
 static void cli_session_init();
 static void cli_finished();
 static void recv_msg_service_accept(void);
+static void cli_session_cleanup(void);
 
 struct clientsession cli_ses; /* GLOBAL */
 
@@ -143,6 +144,7 @@
 
 	/* For printing "remote host closed" for the user */
 	ses.remoteclosed = cli_remoteclosed;
+	ses.extra_session_cleanup = cli_session_cleanup;
 	ses.buf_match_algo = cli_buf_match_algo;
 
 	/* packet handlers */
@@ -290,7 +292,7 @@
 
 }
 
-void cli_session_cleanup() {
+static void cli_session_cleanup(void) {
 
 	if (!sessinitdone) {
 		return;
@@ -308,8 +310,7 @@
 
 static void cli_finished() {
 
-	cli_session_cleanup();
-	common_session_cleanup();
+	session_cleanup();
 	fprintf(stderr, "Connection to %s@%s:%s closed.\n", cli_opts.username,
 			cli_opts.remotehost, cli_opts.remoteport);
 	exit(cli_ses.retval);