zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mic...@apache.org
Subject svn commit: r1353687 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/c/src/zk_hashtable.c
Date Mon, 25 Jun 2012 18:00:30 GMT
Author: michim
Date: Mon Jun 25 18:00:29 2012
New Revision: 1353687

URL: http://svn.apache.org/viewvc?rev=1353687&view=rev
Log:
ZOOKEEPER-1163. Memory leak in zk_hashtable.c:do_insert_watcher_object() (Anupam Chanda via
michim)

Modified:
    zookeeper/branches/branch-3.4/CHANGES.txt
    zookeeper/branches/branch-3.4/src/c/src/zk_hashtable.c

Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1353687&r1=1353686&r2=1353687&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Mon Jun 25 18:00:29 2012
@@ -55,6 +55,9 @@ BUGFIXES:
 
   ZOOKEEPER-1431. zkpython async calls leak memory (Kapil Thangavelu and Andre Cruz via henryr)
 
+  ZOOKEEPER-1163. Memory leak in zk_hashtable.c:do_insert_watcher_object()
+  (Anupam Chanda via michim)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1389. it would be nice if start-foreground used exec $JAVA

Modified: zookeeper/branches/branch-3.4/src/c/src/zk_hashtable.c
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/c/src/zk_hashtable.c?rev=1353687&r1=1353686&r2=1353687&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/c/src/zk_hashtable.c (original)
+++ zookeeper/branches/branch-3.4/src/c/src/zk_hashtable.c Mon Jun 25 18:00:29 2012
@@ -189,8 +189,12 @@ static int do_insert_watcher_object(zk_h
         res=hashtable_insert(ht->ht,strdup(path),create_watcher_object_list(wo));
         assert(res);
     }else{
-        /* path already exists; check if the watcher already exists */
-        res = add_to_list(&wl, wo, 1);
+        /*
+         * Path already exists; check if the watcher already exists.
+         * Don't clone the watcher since it's allocated on the heap --- avoids
+         * a memory leak and saves a clone operation (calloc + copy).
+         */
+        res = add_to_list(&wl, wo, 0);
     }
     return res;    
 }



Mime
View raw message