You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2018/09/05 13:28:32 UTC

[trafficserver] 03/03: Log Collation - Memory leak when more than one active host defined.

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit e9055061a02def98a12a64db6d0a887ca8635170
Author: Peter Chou <pb...@labs.att.com>
AuthorDate: Mon Jul 30 23:35:37 2018 -0700

    Log Collation - Memory leak when more than one active host defined.
    
    When more than one active host is defined, there is a memory leak because LogHostList::preproc_and_try_delete() allocates one
    LogBuffer reference per host but only destroys one reference at the end of the function. The reference increments and destroys
    must be balanced to ensure that LogBuffers are deleted properly.
    
    (cherry picked from commit 4a115df3d02db3ee50b2038f5c1cd4b12248b3b6)
---
 proxy/logging/LogHost.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/proxy/logging/LogHost.cc b/proxy/logging/LogHost.cc
index d2c0e4e..ea2cead 100644
--- a/proxy/logging/LogHost.cc
+++ b/proxy/logging/LogHost.cc
@@ -406,14 +406,14 @@ int
 LogHostList::preproc_and_try_delete(LogBuffer *lb)
 {
   int success = false;
-  unsigned nr_host, nr;
+  unsigned nr;
   bool need_orphan        = true;
   LogHost *available_host = nullptr;
 
   ink_release_assert(lb->m_references == 0);
 
-  nr_host = nr = count();
-  ink_atomic_increment(&lb->m_references, nr_host);
+  nr = count();
+  ink_atomic_increment(&lb->m_references, 1);
 
   for (LogHost *host = first(); host && nr; host = next(host)) {
     LogHost *lh    = host;