From: Art Cancro Date: Mon, 8 May 2006 03:30:49 +0000 (+0000) Subject: Call endtls() when an HTTP session ends normally -- not X-Git-Tag: v7.86~4025 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=644638af3fe46f8885ca81c5f872e451494d8c91 Call endtls() when an HTTP session ends normally -- not just when it sends abnormally. This fixes that huge memory leak I've been trying to find all this time. --- diff --git a/webcit/crypto.c b/webcit/crypto.c index 77ba8947c..cb6e22a20 100644 --- a/webcit/crypto.c +++ b/webcit/crypto.c @@ -385,9 +385,15 @@ void endtls(void) lprintf(5, "Ending SSL/TLS\n"); SSL_shutdown(THREADSSL); ctx = SSL_get_SSL_CTX(THREADSSL); - if (ctx != NULL) { - SSL_CTX_free(ctx); - } + + /** I don't think this is needed, and it crashes the server anyway + * + * if (ctx != NULL) { + * lprintf(9, "Freeing CTX at %x\n", (int)ctx ); + * SSL_CTX_free(ctx); + * } + */ + SSL_free(THREADSSL); pthread_setspecific(ThreadSSL, NULL); } diff --git a/webcit/webcit.h b/webcit/webcit.h index 31c9b92b5..a97b2f4a6 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -23,6 +23,7 @@ #ifdef HAVE_LIMITS_H #include #endif +#include #include #include #include diff --git a/webcit/webserver.c b/webcit/webserver.c index 7a43269e2..8e86431dd 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -751,8 +751,15 @@ void worker_entry(void) #endif if (fail_this_transaction == 0) { + /** Perform an HTTP transaction... */ context_loop(ssock); + + /** Shut down SSL/TLS if required... */ + if (is_https) { + endtls(); + } + /** ...and close the socket. */ lingering_close(ssock); }