]> granicus.if.org Git - apache/commitdiff
* Don't leak memory when reopening the logfile.
authorRuediger Pluem <rpluem@apache.org>
Mon, 28 Jan 2008 14:51:14 +0000 (14:51 +0000)
committerRuediger Pluem <rpluem@apache.org>
Mon, 28 Jan 2008 14:51:14 +0000 (14:51 +0000)
PR: 40183
Submitted by: rpluem, Takashi Sato <serai lans-tv.com>
Reviewed by: rpluem

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@615901 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
support/rotatelogs.c

diff --git a/CHANGES b/CHANGES
index 90c8ad3282399168eb4d1ed0fda94ca5809aa91b..56047eef015a468ffad6a0701e39d821a5c52b9e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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+)
index c339c3b6c87ead9ac91e5c486e63dc813e7c4374..3bd958decd705096818e900486b9496ef0b1411c 100644 (file)
@@ -120,6 +120,8 @@ int main (int argc, const char * const argv[])
     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 @@ int main (int argc, const char * const argv[])
                 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 @@ int main (int argc, const char * const argv[])
                 }
                 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 @@ int main (int argc, const char * const argv[])
             }
             else if (nLogFDprev) {
                 apr_file_close(nLogFDprev);
+                if (pfile_prev) {
+                    apr_pool_destroy(pfile_prev);
+                }
             }
             nMessCount = 0;
         }