From bb28ee9a6331822dab9748766444de652447e620 Mon Sep 17 00:00:00 2001 From: Alexander Vdolainen Date: Sat, 25 Jul 2015 01:07:55 +0300 Subject: [PATCH] fixed; --- lib/sntllv2.c | 23 +++++++++++++---------- tests/lv2sd.c | 15 ++------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/lib/sntllv2.c b/lib/sntllv2.c index 5b4b78d..a7f7dff 100644 --- a/lib/sntllv2.c +++ b/lib/sntllv2.c @@ -466,22 +466,25 @@ static void __connection_destroy(conn_t *co) } pthread_mutex_unlock(&co->idx_msg_lock); - /* ok now we will free the channels */ - pthread_mutex_lock(&co->idx_ch_lock); - for(i = 0; i < 512; i++) { - chan = co->channels[i]; - if(!chan) continue; - idx_free(&co->idx_ch, i); - free(chan); - } - pthread_mutex_unlock(&co->idx_ch_lock); - /* update use count */ _CONN_NOTINUSE(co); /* ok, let's free other if we can */ if(!_CONN_UCOUNT(co)) { + /* ok now we will free the channels */ + pthread_mutex_lock(&co->idx_ch_lock); + for(i = 0; i < 512; i++) { + chan = co->channels[i]; + if(!chan) continue; + idx_free(&co->idx_ch, i); + free(chan); + } + pthread_mutex_unlock(&co->idx_ch_lock); + if(ssys->on_destroy) ssys->on_destroy(co); + if(co->pctx->login) free(co->pctx->login); + if(co->pctx->passwd) free(co->pctx->passwd); + SSL_shutdown(co->ssl); close(SSL_get_fd(co->ssl)); SSL_free(co->ssl); diff --git a/tests/lv2sd.c b/tests/lv2sd.c index 6fd8809..feb455b 100644 --- a/tests/lv2sd.c +++ b/tests/lv2sd.c @@ -170,24 +170,13 @@ static void sigpipe_handler(int a) int main(int argc, char **argv) { - // set detailed signal handler - // struct sigaction sigact, sigpipe; - // sigact.sa_flags = SA_SIGINFO; - // sigact.sa_sigaction = signal_error; - // sigemptyset(&sigact.sa_mask); - // sigaction(SIGFPE, &sigact, 0); - // sigaction(SIGILL, &sigact, 0); - // sigaction(SIGSEGV, &sigact, 0); - // sigaction(SIGBUS, &sigact, 0); - - // memset(&sigpipe, 0, sizeof(struct sigaction)); - // sigpipe.sa_handler = sigpipe_handler; - // sigaction(SIGPIPE, &sigpipe, NULL); char *rootca = NULL, *cert = NULL; conn_sys_t *ssys = connections_create(); int port = DEFAULT_PORT; int opt; + signal(SIGPIPE, SIG_IGN); + while((opt = getopt(argc, argv, "p:r:u:")) != -1) { switch(opt) { case 'p':