Browse Source

ZOOKEEPER-888: c-client / zkpython: Double free corruption on node
watcher (Austin Shoemaker via henryr)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@1024358 13f79535-47bb-0310-9956-ffa450edef68

Henry Robinson 15 years ago
parent
commit
ac85ac93af

+ 2 - 0
CHANGES.txt

@@ -117,6 +117,8 @@ BUGFIXES:
   ZOOKEEPER-855. clientPortBindAddress should be clientPortAddress
   ZOOKEEPER-855. clientPortBindAddress should be clientPortAddress
   (Jared Cantwell via fpj)
   (Jared Cantwell via fpj)
 
 
+  ZOOKEEPER-888. c-client / zkpython: Double free corruption on node watcher (Austin Shoemaker via henryr)
+
 IMPROVEMENTS:
 IMPROVEMENTS:
   ZOOKEEPER-724. Improve junit test integration - log harness information 
   ZOOKEEPER-724. Improve junit test integration - log harness information 
   (phunt via mahadev)
   (phunt via mahadev)

+ 2 - 2
src/contrib/zkpython/src/c/zookeeper.c

@@ -436,7 +436,7 @@ void watcher_dispatch(zhandle_t *zzh, int type, int state,
   if (PyObject_CallObject((PyObject*)callback, arglist) == NULL) {
   if (PyObject_CallObject((PyObject*)callback, arglist) == NULL) {
     PyErr_Print();
     PyErr_Print();
   }
   }
-  if (pyw->permanent == 0) {
+  if (pyw->permanent == 0 && (type != ZOO_SESSION_EVENT || is_unrecoverable(zzh))) {
     free_pywatcher(pyw);
     free_pywatcher(pyw);
   }
   }
   PyGILState_Release(gstate);
   PyGILState_Release(gstate);
@@ -1395,7 +1395,7 @@ PyObject *pyis_unrecoverable(PyObject *self, PyObject *args)
     return NULL;
     return NULL;
   CHECK_ZHANDLE(zkhid);
   CHECK_ZHANDLE(zkhid);
   int ret = is_unrecoverable(zhandles[zkhid]);
   int ret = is_unrecoverable(zhandles[zkhid]);
-  if (ret > 0)
+  if (ret == ZINVALIDSTATE)
     Py_RETURN_TRUE;
     Py_RETURN_TRUE;
   Py_RETURN_FALSE;
   Py_RETURN_FALSE;
 }
 }

+ 3 - 1
src/contrib/zkpython/src/test/zktestbase.py

@@ -21,9 +21,11 @@ import unittest, threading, zookeeper
 ZOO_OPEN_ACL_UNSAFE = {"perms":0x1f, "scheme":"world", "id" :"anyone"}
 ZOO_OPEN_ACL_UNSAFE = {"perms":0x1f, "scheme":"world", "id" :"anyone"}
 
 
 class TestBase(unittest.TestCase):
 class TestBase(unittest.TestCase):
+    SERVER_PORT = 22182
+    
     def __init__(self,methodName='runTest'):
     def __init__(self,methodName='runTest'):
         unittest.TestCase.__init__(self,methodName)
         unittest.TestCase.__init__(self,methodName)
-        self.host = "localhost:22182"
+        self.host = "localhost:%d" % self.SERVER_PORT
         self.connected = False
         self.connected = False
         self.handle = -1
         self.handle = -1
         logdir = os.environ.get("ZKPY_LOG_DIR")
         logdir = os.environ.get("ZKPY_LOG_DIR")