From 9b8e801777f2bcc15c6ca1caffca3236b8cf2b75 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 6 May 2017 21:17:28 +0200 Subject: Add more cleanup code on connection loss --- vchat-client.c | 4 +++- 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) /* clear userlist */ ul_clear (); /* close server connection */ - if (serverfd > 0) + if (serverfd > 0) { close (serverfd); + serverfd = -1; + } /* inform user if we where killed by signal */ if (signal > 1) { 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) /* disconnect from server */ void vcdisconnect () { - if (server_conn) - BIO_free_all( server_conn ); - serverfd = -1; + BIO_free_all( server_conn ); + server_conn = 0; + if (serverfd>0) { + close(serverfd); + serverfd = -1; + } } /* handle a pm not sent error -- cgit v1.2.3