svn commit: r1024358 - in /hadoop/zookeeper/trunk: CHANGES.txt src/contrib/zkpython/src/c/zookeeper.c src/contrib/zkpython/src/test/zktestbase.py

2010-10-19 Thread henry
Author: henry
Date: Tue Oct 19 18:57:02 2010
New Revision: 1024358

URL: http://svn.apache.org/viewvc?rev=1024358view=rev
Log:
ZOOKEEPER-888: c-client / zkpython: Double free corruption on node
watcher (Austin Shoemaker via henryr)

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

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=1024358r1=1024357r2=1024358view=diff
==
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Tue Oct 19 18:57:02 2010
@@ -117,6 +117,8 @@ BUGFIXES: 
   ZOOKEEPER-855. clientPortBindAddress should be clientPortAddress
   (Jared Cantwell via fpj)
 
+  ZOOKEEPER-888. c-client / zkpython: Double free corruption on node watcher 
(Austin Shoemaker via henryr)
+
 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=1024358r1=1024357r2=1024358view=diff
==
--- hadoop/zookeeper/trunk/src/contrib/zkpython/src/c/zookeeper.c (original)
+++ hadoop/zookeeper/trunk/src/contrib/zkpython/src/c/zookeeper.c Tue Oct 19 
18:57:02 2010
@@ -436,7 +436,7 @@ void watcher_dispatch(zhandle_t *zzh, in
   if (PyObject_CallObject((PyObject*)callback, arglist) == NULL) {
 PyErr_Print();
   }
-  if (pyw-permanent == 0) {
+  if (pyw-permanent == 0  (type != ZOO_SESSION_EVENT || 
is_unrecoverable(zzh))) {
 free_pywatcher(pyw);
   }
   PyGILState_Release(gstate);
@@ -1395,7 +1395,7 @@ PyObject *pyis_unrecoverable(PyObject *s
 return NULL;
   CHECK_ZHANDLE(zkhid);
   int ret = is_unrecoverable(zhandles[zkhid]);
-  if (ret  0)
+  if (ret == ZINVALIDSTATE)
 Py_RETURN_TRUE;
   Py_RETURN_FALSE;
 }

Modified: hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/zktestbase.py
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/zktestbase.py?rev=1024358r1=1024357r2=1024358view=diff
==
--- hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/zktestbase.py 
(original)
+++ hadoop/zookeeper/trunk/src/contrib/zkpython/src/test/zktestbase.py Tue Oct 
19 18:57:02 2010
@@ -21,9 +21,11 @@ import unittest, threading, zookeeper
 ZOO_OPEN_ACL_UNSAFE = {perms:0x1f, scheme:world, id :anyone}
 
 class TestBase(unittest.TestCase):
+SERVER_PORT = 22182
+
 def __init__(self,methodName='runTest'):
 unittest.TestCase.__init__(self,methodName)
-self.host = localhost:22182
+self.host = localhost:%d % self.SERVER_PORT
 self.connected = False
 self.handle = -1
 logdir = os.environ.get(ZKPY_LOG_DIR)




svn commit: r1024438 - in /hadoop/zookeeper/trunk: CHANGES.txt src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java src/java/test/org/apache/zookeeper/test/CnxManagerTest.java

2010-10-19 Thread phunt
Author: phunt
Date: Tue Oct 19 22:32:09 2010
New Revision: 1024438

URL: http://svn.apache.org/viewvc?rev=1024438view=rev
Log:
ZOOKEEPER-893. ZooKeeper high cpu usage when invalid requests

Modified:
hadoop/zookeeper/trunk/CHANGES.txt

hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java

hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/CnxManagerTest.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=1024438r1=1024437r2=1024438view=diff
==
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Tue Oct 19 22:32:09 2010
@@ -110,14 +110,20 @@ BUGFIXES: 
   ZOOKEEPER-822. Leader election taking a long time to complete
   (Vishal K via phunt)
 
-  ZOOKEEPER-866. Hedwig Server stays in disconnected state when connection 
to ZK dies but gets reconnected (erwin tam via breed)
+  ZOOKEEPER-866. Hedwig Server stays in disconnected state when
+  connection to ZK dies but gets reconnected (erwin tam via breed)
 
-  ZOOKEEPER-881. ZooKeeperServer.loadData loads database twice (jared cantwell 
via breed)
+  ZOOKEEPER-881. ZooKeeperServer.loadData loads database twice
+  (jared cantwell via breed)
 
   ZOOKEEPER-855. clientPortBindAddress should be clientPortAddress
   (Jared Cantwell via fpj)
 
-  ZOOKEEPER-888. c-client / zkpython: Double free corruption on node watcher 
(Austin Shoemaker via henryr)
+  ZOOKEEPER-888. c-client / zkpython: Double free corruption on
+  node watcher (Austin Shoemaker via henryr)
+
+  ZOOKEEPER-893. ZooKeeper high cpu usage when invalid requests
+  (Thijs Terlouw via phunt)
 
 IMPROVEMENTS:
   ZOOKEEPER-724. Improve junit test integration - log harness information 

Modified: 
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
URL: 
http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java?rev=1024438r1=1024437r2=1024438view=diff
==
--- 
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
 (original)
+++ 
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
 Tue Oct 19 22:32:09 2010
@@ -673,28 +673,33 @@ public class QuorumCnxManager {
 }
 msgLength.position(0);
 int length = msgLength.getInt();
+if(length = 0) {
+throw new IOException(Invalid packet length: + 
length);
+}
 /**
  * Allocates a new ByteBuffer to receive the message
  */
-if (length  0) {
-if (length  PACKETMAXSIZE) {
-throw new IOException(Invalid packet of length  
+ length);
-}
-byte[] msgArray = new byte[length];
-ByteBuffer message = ByteBuffer.wrap(msgArray);
-int numbytes = 0;
-while (message.hasRemaining()) {
-numbytes += channel.read(message);
-}
-message.position(0);
-synchronized (recvQueue) {
-recvQueue
-.put(new Message(message.duplicate(), 
sid));
+if (length  PACKETMAXSIZE) {
+throw new IOException(Invalid packet of length  + 
length);
+}
+byte[] msgArray = new byte[length];
+ByteBuffer message = ByteBuffer.wrap(msgArray);
+int numbytes = 0;
+int temp_numbytes = 0;
+while (message.hasRemaining()) {
+temp_numbytes = channel.read(message); 
+if(temp_numbytes  0) {
+throw new IOException(Channel eof before end);
 }
-msgLength.position(0);
+numbytes += temp_numbytes;
+}
+message.position(0);
+synchronized (recvQueue) {
+recvQueue
+.put(new Message(message.duplicate(), sid));
 }
+msgLength.position(0);
 }
-
 } catch (Exception e) {
 LOG.warn(Connection broken for id  + sid + , my id =  + 
 self.getId() + , error =  + e);

Modified: 
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/CnxManagerTest.java
URL: