trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject git commit: TS-2276: manager memory leak in some case
Date Thu, 31 Oct 2013 10:35:29 GMT
Updated Branches:
  refs/heads/master e819a5f1b -> 316b45041


TS-2276: manager memory leak in some case


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/316b4504
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/316b4504
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/316b4504

Branch: refs/heads/master
Commit: 316b450415f41cf80dca05f18538aa27c53b7b51
Parents: e819a5f
Author: Yu Qing <zhuangyuan@taobao.com>
Authored: Fri Oct 18 14:45:30 2013 +0800
Committer: Zhao Yongming <ming.zym@gmail.com>
Committed: Thu Oct 31 18:33:41 2013 +0800

----------------------------------------------------------------------
 CHANGES                      |  3 +++
 mgmt/Alarms.cc               | 14 +-------------
 mgmt/Alarms.h                |  2 +-
 mgmt/api/EventControlMain.cc |  2 +-
 mgmt/utils/MgmtHashTable.h   | 18 +++++++++++++++++-
 5 files changed, 23 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/316b4504/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 3dc9a51..fb18b34 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 Changes with Apache Traffic Server 4.1.0
 
 
+  *) [TS-2276] manager memory leak in some case.
+   Author: Yu Qing
+
   *( [TS-1638] less strict on kernel version checking in clustering.
    Author: Yu Qing
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/316b4504/mgmt/Alarms.cc
----------------------------------------------------------------------
diff --git a/mgmt/Alarms.cc b/mgmt/Alarms.cc
index c655d90..cbf2dc0 100644
--- a/mgmt/Alarms.cc
+++ b/mgmt/Alarms.cc
@@ -347,21 +347,9 @@ Alarms::signalAlarm(alarm_t a, const char *desc, const char *ip)
 
   for (entry = ink_hash_table_iterator_first(cblist, &iterator_state);
        entry != NULL; entry = ink_hash_table_iterator_next(cblist, &iterator_state))
{
-    char *tmp, *tmp2;
     AlarmCallbackFunc func = (AlarmCallbackFunc) ink_hash_table_entry_value(remote_alarms,
entry);
-    if (ip) {
-      tmp = (char *)ats_strdup(ip);
-    } else {
-      tmp = NULL;
-    }
-
-    if (desc) {
-      tmp2 = ats_strdup(desc);
-    } else {
-      tmp2 = NULL;
-    }
     Debug("alarm", "[Alarms::signalAlarm] invoke callback for %d", a);
-    (*(func)) (a, tmp, tmp2);
+    (*(func)) (a, ip, desc);
   }
   /* Priority 2 alarms get signalled if they are the first unsolved occurence. */
   if (priority == 2 && alarm_bin && alarm_bin_path && !ip) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/316b4504/mgmt/Alarms.h
----------------------------------------------------------------------
diff --git a/mgmt/Alarms.h b/mgmt/Alarms.h
index 82dc282..23bc81c 100644
--- a/mgmt/Alarms.h
+++ b/mgmt/Alarms.h
@@ -88,7 +88,7 @@ const int minOEMkey = 1000;     // used as offset
 const int maxOEMkey = 6000;
 
 typedef int alarm_t;
-typedef void (*AlarmCallbackFunc) (alarm_t, char *, char *);
+typedef void (*AlarmCallbackFunc) (alarm_t, const char *, const char *);
 
 typedef struct _alarm
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/316b4504/mgmt/api/EventControlMain.cc
----------------------------------------------------------------------
diff --git a/mgmt/api/EventControlMain.cc b/mgmt/api/EventControlMain.cc
index 3b500c2..ffc9c8b 100644
--- a/mgmt/api/EventControlMain.cc
+++ b/mgmt/api/EventControlMain.cc
@@ -200,7 +200,7 @@ delete_event_queue(LLQ * q)
  * note: None
  *********************************************************************/
 void
-apiEventCallback(alarm_t newAlarm, char * /* ip ATS_UNUSED */, char *desc)
+apiEventCallback(alarm_t newAlarm, const char * /* ip ATS_UNUSED */, const char *desc)
 {
   // create an TSEvent
   // addEvent(new_alarm, ip, desc) // adds event to mgmt_events

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/316b4504/mgmt/utils/MgmtHashTable.h
----------------------------------------------------------------------
diff --git a/mgmt/utils/MgmtHashTable.h b/mgmt/utils/MgmtHashTable.h
index 4ec435e..1c5274a 100644
--- a/mgmt/utils/MgmtHashTable.h
+++ b/mgmt/utils/MgmtHashTable.h
@@ -81,9 +81,25 @@ public:
 
   int mgmt_hash_table_delete(InkHashTableKey key)
   {
+    InkHashTableEntry *entry;
     int ret;
     ink_mutex_acquire(&mutex);
-    ret = ink_hash_table_delete(ht, key);
+    if (destroy_and_free) {
+      entry = ink_hash_table_lookup_entry(ht, key);
+      if (entry != NULL) {
+        InkHashTableValue value = ink_hash_table_entry_value(ht, entry);
+        if (value != NULL) {
+          ats_free(value);
+        }
+        ret = ink_hash_table_delete(ht, key);
+      }
+      else {  //not found
+        ret = 0;
+      }
+    }
+    else {
+      ret = ink_hash_table_delete(ht, key);
+    }
     ink_mutex_release(&mutex);
     return ret;
   }                             /* End MgmtHashTable::mgmt_hash_table_delete */


Mime
View raw message