Author: phunt
Date: Wed May 19 06:37:49 2010
New Revision: 946047

URL: http://svn.apache.org/viewvc?rev=946047&view=rev
Log:
ZOOKEEPER-772. zkpython segfaults when watcher from async get children is 
invoked.

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/contrib/zkpython/src/c/zookeeper.c
    hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/get_set_test.py

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=946047&r1=946046&r2=946047&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Wed May 19 06:37:49 2010
@@ -55,6 +55,9 @@ BUGFIXES: 
   ZOOKEEPER-774. Recipes tests are slightly outdated: they do not compile
   against JUnit 4.8 (Sergey Doroshenko via phunt)
 
+  ZOOKEEPER-772. zkpython segfaults when watcher from async get children is
+  invoked. (henry via phunt)
+
 IMPROVEMENTS:
   ZOOKEEPER-724. Improve junit test integration - log harness information 
   (phunt via mahadev)

Modified: hadoop/zookeeper/trunk/src/contrib/zkpython/src/c/zookeeper.c
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/zkpython/src/c/zookeeper.c?rev=946047&r1=946046&r2=946047&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/zkpython/src/c/zookeeper.c (original)
+++ hadoop/zookeeper/trunk/src/contrib/zkpython/src/c/zookeeper.c Wed May 19 
06:37:49 2010
@@ -842,7 +842,7 @@ PyObject *pyzoo_aget_children(PyObject *
   int err = zoo_awget_children( zhandles[zkhid],
                                 path,
                                 get_watch != Py_None ? watcher_dispatch : NULL,
-                                pyw,
+                                get_pyw,
                                 strings_completion_dispatch,
                                 pyw);
   if (err != ZOK) {

Modified: hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/get_set_test.py
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/get_set_test.py?rev=946047&r1=946046&r2=946047&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/get_set_test.py 
(original)
+++ hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/get_set_test.py Wed 
May 19 06:37:49 2010
@@ -155,5 +155,34 @@ class GetSetTest(zktestbase.TestBase):
         self.assertEqual(len(self.children), 1, "Expected to find 1 child, got 
" + str(len(self.children)))
 
 
+    def test_async_getchildren_with_watcher(self):
+        self.ensureCreated("/zk-python-getchildrentest", flags=0)
+        self.ensureCreated("/zk-python-getchildrentest/child")
+
+        watched = []
+
+        def watcher(*args):
+            self.cv.acquire()
+            watched.append(args)
+            self.cv.notify()
+            self.cv.release()
+
+        def children_callback(*args):
+            self.cv.acquire()
+            self.cv.notify()
+            self.cv.release()
+
+        zookeeper.aget_children(
+            self.handle, "/zk-python-getchildrentest", watcher, 
children_callback)
+
+        self.cv.acquire()
+        self.cv.wait()
+        self.cv.release()
+
+        self.cv.acquire()
+        self.ensureCreated("/zk-python-getchildrentest/child2")
+        self.cv.wait(15)
+        self.assertTrue(watched)
+
 if __name__ == '__main__':
     unittest.main()


Reply via email to