hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject svn commit: r882328 - in /hadoop/zookeeper/branches/branch-3.2: CHANGES.txt src/contrib/zkpython/src/c/zookeeper.c src/contrib/zkpython/src/test/get_set_test.py src/contrib/zkpython/src/test/zktestbase.py
Date Thu, 19 Nov 2009 22:14:16 GMT
Author: phunt
Date: Thu Nov 19 22:14:16 2009
New Revision: 882328

URL: http://svn.apache.org/viewvc?rev=882328&view=rev
Log:
ZOOKEEPER-554. zkpython can segfault when statting a deleted node

Modified:
    hadoop/zookeeper/branches/branch-3.2/CHANGES.txt
    hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/c/zookeeper.c
    hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/test/get_set_test.py
    hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/test/zktestbase.py

Modified: hadoop/zookeeper/branches/branch-3.2/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.2/CHANGES.txt?rev=882328&r1=882327&r2=882328&view=diff
==============================================================================
--- hadoop/zookeeper/branches/branch-3.2/CHANGES.txt (original)
+++ hadoop/zookeeper/branches/branch-3.2/CHANGES.txt Thu Nov 19 22:14:16 2009
@@ -18,6 +18,9 @@
 
   ZOOKEEPER-541. zkpython limited to 256 handles (henry robinson via phunt)
 
+  ZOOKEEPER-554. zkpython can segfault when statting a deleted node
+  (henry robinson via phunt)
+
   ZOOKEEPER-562. c client can flood server with pings if tcp send queue
   filled. (ben reed via mahadev)
 

Modified: hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/c/zookeeper.c
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/c/zookeeper.c?rev=882328&r1=882327&r2=882328&view=diff
==============================================================================
--- hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/c/zookeeper.c (original)
+++ hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/c/zookeeper.c Thu Nov 19
22:14:16 2009
@@ -203,6 +203,9 @@
 
 PyObject *build_stat( const struct Stat *stat )
 {
+	if (stat == NULL) { 
+		return Py_None;
+	}
   return Py_BuildValue( "{s:K, s:K, s:K, s:K,"
 			"s:i, s:i, s:i, s:K,"
 			"s:i, s:i, s:K}",

Modified: hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/test/get_set_test.py
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/test/get_set_test.py?rev=882328&r1=882327&r2=882328&view=diff
==============================================================================
--- hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/test/get_set_test.py (original)
+++ hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/test/get_set_test.py Thu
Nov 19 22:14:16 2009
@@ -44,6 +44,33 @@
                           "test",
                           stat["version"]+1)
 
+    def test_stat_deleted_node(self):
+        """
+        Test for a bug that surfaced when trying to build a
+        stat object from a non-existant node.
+
+        """
+        self.ensureDeleted("/zk-python-test-deleteme")
+        self.assertRaises(zookeeper.NoNodeException,
+                          zookeeper.get,
+                          self.handle,
+                          "/zk-python-test-deleteme")
+        self.cv = threading.Condition()
+        def callback(handle, rc, value, stat):
+            self.cv.acquire()
+            self.stat = stat
+            self.rc = rc
+            self.value = value
+            self.callback_flag = True
+            self.cv.notify()
+            self.cv.release()
+        self.cv.acquire()
+        zookeeper.aget(self.handle, "/zk-python-test-deleteme", None, callback)
+        self.cv.wait(15)
+        self.assertEqual(self.callback_flag, True, "aget timed out!")
+        self.assertEqual(self.stat, None, "Stat should be none!")
+        self.assertEqual(self.value, None, "Value should be none!")
+
     def test_async_getset(self):
         self.cv = threading.Condition()
         def get_callback(handle, rc, value, stat):

Modified: hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/test/zktestbase.py
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/test/zktestbase.py?rev=882328&r1=882327&r2=882328&view=diff
==============================================================================
--- hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/test/zktestbase.py (original)
+++ hadoop/zookeeper/branches/branch-3.2/src/contrib/zkpython/src/test/zktestbase.py Thu Nov
19 22:14:16 2009
@@ -72,7 +72,7 @@
         return handle
 
     def ensureDeleted(self,path):
-        self.assertEqual(zookeeper.STATE_CONNECTED, zookeeper.state(self.handle), "Not connected!")
+        self.assertEqual(zookeeper.CONNECTED_STATE, zookeeper.state(self.handle), "Not connected!")
         try:
             self.assertEqual(zookeeper.OK, zookeeper.delete(self.handle, path))
         except zookeeper.NoNodeException:



Mime
View raw message