On 2016-11-14 00:17:31 [+0100], gregor herrmann wrote: > Thanks, but nope, still the same:
What about this one? Sebastian
>From b436cd6527a2a32bd94b67ff10363e45a2f52430 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior <sebast...@breakpoint.cc> Date: Mon, 14 Nov 2016 21:03:24 +0000 Subject: [PATCH] take #2 --- src/client.c | 22 +++++++++++++++++++++- src/tls.c | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/client.c b/src/client.c index e2648d26eda3..581ca43a3372 100644 --- a/src/client.c +++ b/src/client.c @@ -131,11 +131,31 @@ void client_main(CLI *c) { c->fds=NULL; str_stats(); /* client thread allocation tracking */ /* c allocation is detached, so it is safe to call str_stats() */ - if(service_options.next) /* no tls_cleanup() in inetd mode */ + if(service_options.next) { /* no tls_cleanup() in inetd mode */ + SSL_SESSION *old_session; + + CRYPTO_THREAD_write_lock(stunnel_locks[LOCK_SESSION]); + old_session = c->opt->session; + c->opt->session = NULL; + CRYPTO_THREAD_write_unlock(stunnel_locks[LOCK_SESSION]); + if (old_session) + SSL_SESSION_free(old_session); /* release the old one */ + tls_cleanup(); + } } } else client_run(c); + { + SSL_SESSION *old_session; + + CRYPTO_THREAD_write_lock(stunnel_locks[LOCK_SESSION]); + old_session = c->opt->session; + c->opt->session = NULL; + CRYPTO_THREAD_write_unlock(stunnel_locks[LOCK_SESSION]); + if (old_session) + SSL_SESSION_free(old_session); /* release the old one */ + } str_free(c); } diff --git a/src/tls.c b/src/tls.c index 3964f9ce6f2d..8b2b18938d74 100644 --- a/src/tls.c +++ b/src/tls.c @@ -100,6 +100,7 @@ void tls_cleanup() { tls_data=tls_get(); if(!tls_data) return; + OPENSSL_thread_stop(); str_cleanup(tls_data); str_free(tls_data->id); /* detached allocation */ tls_set(NULL); -- 2.10.2