Call endtls() when an HTTP session ends normally -- not
authorArt Cancro <ajc@citadel.org>
Mon, 8 May 2006 03:30:49 +0000 (03:30 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 8 May 2006 03:30:49 +0000 (03:30 +0000)
just when it sends abnormally.  This fixes that huge memory
leak I've been trying to find all this time.

webcit/crypto.c
webcit/webcit.h
webcit/webserver.c

index 77ba8947c210847b98fe290cfa51835a99cfb323..cb6e22a20d9336599090c766a07a013095518a44 100644 (file)
@@ -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);
 }
index 31c9b92b5250d0b571e75b8c76a320f59f7aa797..a97b2f4a62e1b2abeb5607ad5e0c521192a0f550 100644 (file)
@@ -23,6 +23,7 @@
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #endif
+#include <malloc.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <sys/un.h>
index 7a43269e2a0966437065635c6571feec37ef2977..8e86431dda7cba746eb190a872e63ce6cac08201 100644 (file)
@@ -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);
                        }