httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpl...@apache.org
Subject svn commit: r615901 - in /httpd/httpd/trunk: CHANGES support/rotatelogs.c
Date Mon, 28 Jan 2008 14:51:15 GMT
Author: rpluem
Date: Mon Jan 28 06:51:14 2008
New Revision: 615901

URL: http://svn.apache.org/viewvc?rev=615901&view=rev
Log:
* Don't leak memory when reopening the logfile.

PR: 40183
Submitted by: rpluem, Takashi Sato <serai lans-tv.com>
Reviewed by: rpluem

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/support/rotatelogs.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=615901&r1=615900&r2=615901&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Mon Jan 28 06:51:14 2008
@@ -2,6 +2,9 @@
 Changes with Apache 2.3.0
 [ When backported to 2.2.x, remove entry from this file ]
 
+  *) rotatelogs: Don't leak memory when reopening the logfile.
+     PR 40183 [Ruediger Pluem, Takashi Sato <serai lans-tv.com>]
+
   *) mod_ldap: Add support (taking advantage of the new APR capability)
      for ldap rebind callback while chasing referrals. This allows direct
      searches on LDAP servers (in particular MS Active Directory 2003+)

Modified: httpd/httpd/trunk/support/rotatelogs.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/support/rotatelogs.c?rev=615901&r1=615900&r2=615901&view=diff
==============================================================================
--- httpd/httpd/trunk/support/rotatelogs.c (original)
+++ httpd/httpd/trunk/support/rotatelogs.c Mon Jan 28 06:51:14 2008
@@ -120,6 +120,8 @@
     const char *szLogRoot;
     apr_file_t *f_stdin, *nLogFD = NULL, *nLogFDprev = NULL;
     apr_pool_t *pool;
+    apr_pool_t *pfile = NULL;
+    apr_pool_t *pfile_prev = NULL;
     apr_getopt_t *opt;
     apr_status_t rv;
     char c;
@@ -233,8 +235,10 @@
                 sprintf(buf2, "%s.%010d", szLogRoot, tLogStart);
             }
             tLogEnd = tLogStart + tRotation;
+            pfile_prev = pfile;
+            apr_pool_create(&pfile, pool);
             rv = apr_file_open(&nLogFD, buf2, APR_WRITE | APR_CREATE | APR_APPEND,
-                               APR_OS_DEFAULT, pool);
+                               APR_OS_DEFAULT, pfile);
             if (rv != APR_SUCCESS) {
                 char error[120];
 
@@ -249,6 +253,8 @@
                 }
                 else {
                     nLogFD = nLogFDprev;
+                    apr_pool_destroy(pfile);
+                    pfile = pfile_prev;
                     /* Try to keep this error message constant length
                      * in case it occurs several times. */
                     apr_snprintf(errbuf, sizeof errbuf,
@@ -265,6 +271,9 @@
             }
             else if (nLogFDprev) {
                 apr_file_close(nLogFDprev);
+                if (pfile_prev) {
+                    apr_pool_destroy(pfile_prev);
+                }
             }
             nMessCount = 0;
         }



Mime
View raw message