I've noticed a leak of an nsopenssl object during cleanup of driver
sockets.  It only occurs when a socket is kept open because of keepalive
and then timed out when the keepalive time limit has been reached.  In
that case the socket is freed without calling the freeing routines of the
nsopenssl driver.

The following patch is a proposed solution to solve this (the comments can
be changed).  Also, there was as assignment of the sockPtr->keep inside
and outside of the Mutex.  This patch also removes the assignment outside
of the mutex.

Index: driver.c
===================================================================
RCS file: /cvsroot/aolserver/aolserver/nsd/driver.c,v
retrieving revision 1.17.2.9
diff -u -w -r1.17.2.9 driver.c
--- driver.c    17 Sep 2004 15:30:58 -0000      1.17.2.9
+++ driver.c    1 Mar 2005 16:30:49 -0000
@@ -706,7 +706,7 @@
     if (!keep) {
        (void) (*sockPtr->drvPtr->proc)(DriverClose, sock, NULL, 0);
     }
-    sockPtr->keep = keep;
+
     Ns_MutexLock(&lock);
     if (firstClosePtr == NULL) {
        trigger = 1;
@@ -1295,6 +1295,22 @@
             && (sockPtr->drvPtr->loggingFlags & LOGGING_READTIMEOUT) ) {
             errMsg = "Timeout during read";
         }
+        /*
+         * XXX
+         * - Close the driver...
+         * - does sockPtr->arg need to be checked for NULLness or trust
+         *   the driver to do that?
+         * - does it hurt to call this every single time?
+         *
+         * If we got to this point, then we know we have a socket and
+         * this socket hasn't had it's destructor called on it since it
+         * will have been in a keep-alive state, so if we don't do this
+         * then all memory allocated to it will be lost when ns_sockclose
+         * is called below
+         */
+        (void) (*sockPtr->drvPtr->proc)(DriverClose,
+                (Ns_Sock *) sockPtr, NULL, 0);
+
         break;
     case Reason_ServerReject:
         if (sockPtr->drvPtr->loggingFlags & LOGGING_SERVERREJECT) {


-- AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to