diff options
author | Dirk Engling <erdgeist@erdgeist.org> | 2017-05-06 21:17:28 +0200 |
---|---|---|
committer | Dirk Engling <erdgeist@erdgeist.org> | 2017-05-06 21:17:28 +0200 |
commit | 9b8e801777f2bcc15c6ca1caffca3236b8cf2b75 (patch) | |
tree | 90908a7429ff977b786b0ce8a2608f9d9bdadf70 | |
parent | d2ffe887bed0fb9741e39df1298c3e14eb7383a6 (diff) |
Add more cleanup code on connection loss
-rwxr-xr-x | vchat-client.c | 4 | ||||
-rwxr-xr-x | vchat-protocol.c | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/vchat-client.c b/vchat-client.c index a2e298c..0e480be 100755 --- a/vchat-client.c +++ b/vchat-client.c | |||
@@ -355,8 +355,10 @@ cleanup (int signal) | |||
355 | /* clear userlist */ | 355 | /* clear userlist */ |
356 | ul_clear (); | 356 | ul_clear (); |
357 | /* close server connection */ | 357 | /* close server connection */ |
358 | if (serverfd > 0) | 358 | if (serverfd > 0) { |
359 | close (serverfd); | 359 | close (serverfd); |
360 | serverfd = -1; | ||
361 | } | ||
360 | /* inform user if we where killed by signal */ | 362 | /* inform user if we where killed by signal */ |
361 | if (signal > 1) | 363 | if (signal > 1) |
362 | { | 364 | { |
diff --git a/vchat-protocol.c b/vchat-protocol.c index 88631ef..f1b71a1 100755 --- a/vchat-protocol.c +++ b/vchat-protocol.c | |||
@@ -192,9 +192,12 @@ vcconnect (char *server, char *port) | |||
192 | /* disconnect from server */ | 192 | /* disconnect from server */ |
193 | void | 193 | void |
194 | vcdisconnect () { | 194 | vcdisconnect () { |
195 | if (server_conn) | 195 | BIO_free_all( server_conn ); |
196 | BIO_free_all( server_conn ); | 196 | server_conn = 0; |
197 | serverfd = -1; | 197 | if (serverfd>0) { |
198 | close(serverfd); | ||
199 | serverfd = -1; | ||
200 | } | ||
198 | } | 201 | } |
199 | 202 | ||
200 | /* handle a pm not sent error | 203 | /* handle a pm not sent error |