comparison svr-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 78eda530c000
children 077bbe1eb220
comparison
equal deleted inserted replaced
732:2e5f2bc60e40 733:70811267715c
70 &svr_chan_tcpdirect, 70 &svr_chan_tcpdirect,
71 #endif 71 #endif
72 NULL /* Null termination is mandatory. */ 72 NULL /* Null termination is mandatory. */
73 }; 73 };
74 74
75 static void
76 svr_session_cleanup(void)
77 {
78 /* free potential public key options */
79 svr_pubkey_options_cleanup();
80 }
81
75 void svr_session(int sock, int childpipe) { 82 void svr_session(int sock, int childpipe) {
76 char *host, *port; 83 char *host, *port;
77 size_t len; 84 size_t len;
78 85
79 crypto_init(); 86 crypto_init();
101 get_socket_address(ses.sock_in, NULL, NULL, 108 get_socket_address(ses.sock_in, NULL, NULL,
102 &svr_ses.remotehost, NULL, 1); 109 &svr_ses.remotehost, NULL, 1);
103 110
104 /* set up messages etc */ 111 /* set up messages etc */
105 ses.remoteclosed = svr_remoteclosed; 112 ses.remoteclosed = svr_remoteclosed;
113 ses.extra_session_cleanup = svr_session_cleanup;
106 114
107 /* packet handlers */ 115 /* packet handlers */
108 ses.packettypes = svr_packettypes; 116 ses.packettypes = svr_packettypes;
109 ses.buf_match_algo = svr_buf_match_algo; 117 ses.buf_match_algo = svr_buf_match_algo;
110 118
158 /* For uclinux only the main server process should cleanup - we don't want 166 /* For uclinux only the main server process should cleanup - we don't want
159 * forked children doing that */ 167 * forked children doing that */
160 if (svr_ses.server_pid == getpid()) 168 if (svr_ses.server_pid == getpid())
161 #endif 169 #endif
162 { 170 {
163 /* free potential public key options */
164 svr_pubkey_options_cleanup();
165
166 /* must be after we've done with username etc */ 171 /* must be after we've done with username etc */
167 common_session_cleanup(); 172 session_cleanup();
168 } 173 }
169 174
170 exit(exitcode); 175 exit(exitcode);
171 176
172 } 177 }