From: Ruediger Pluem Date: Mon, 28 Jan 2008 14:51:14 +0000 (+0000) Subject: * Don't leak memory when reopening the logfile. X-Git-Tag: 2.3.0~1014 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e8ab44160bc7bbe547105df2def383d8c937b59;p=apache * Don't leak memory when reopening the logfile. PR: 40183 Submitted by: rpluem, Takashi Sato Reviewed by: rpluem git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@615901 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 90c8ad3282..56047eef01 100644 --- 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 ] + *) 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+) diff --git a/support/rotatelogs.c b/support/rotatelogs.c index c339c3b6c8..3bd958decd 100644 --- a/support/rotatelogs.c +++ b/support/rotatelogs.c @@ -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; }