Forráskód Böngészése

ZOOKEEPER-551. unnecessary SetWatches message on new session (phunt via flavio)


git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@833932 13f79535-47bb-0310-9956-ffa450edef68
Flavio Paiva Junqueira 15 éve
szülő
commit
b1b3bd1186

+ 3 - 0
CHANGES.txt

@@ -103,6 +103,9 @@ BUGFIXES:
   ZOOKEEPER-537. The zookeeper jar includes the java source files
   (Thomas Dudziak via phunt)
 
+  ZOOKEEPER-551. unnecessary SetWatches message on new session.
+  (phunt via flavio)
+
 IMPROVEMENTS:
   ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to
   "socket reuse" and failure to close client (phunt via mahadev)

+ 6 - 0
src/c/src/zookeeper.c

@@ -1170,6 +1170,12 @@ static int send_set_watches(zhandle_t *zh)
     struct SetWatches req;
     int rc;
 
+    // return if there are no pending watches
+    if (!req.dataWatches.count && !req.existWatches.count &&
+        !req.childWatches.count) {
+        return ZOK;
+    }
+
     oa = create_buffer_oarchive();
     req.relativeZxid = zh->last_zxid;
     req.dataWatches.data = collect_keys(zh->active_node_watchers, &req.dataWatches.count);

+ 6 - 1
src/java/main/org/apache/zookeeper/ClientCnxn.java

@@ -851,7 +851,12 @@ public class ClientCnxn {
             bb.rewind();
             synchronized (outgoingQueue) {
                 // We add backwards since we are pushing into the front
-                if (!disableAutoWatchReset) {
+                // Only send if there's a pending watch
+                if (!disableAutoWatchReset &&
+                        (!zooKeeper.getDataWatches().isEmpty()
+                         || !zooKeeper.getExistWatches().isEmpty()
+                         || !zooKeeper.getChildWatches().isEmpty()))
+                {
                     SetWatches sw = new SetWatches(lastZxid,
                             zooKeeper.getDataWatches(),
                             zooKeeper.getExistWatches(),