You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by ma...@apache.org on 2009/10/29 22:04:45 UTC
svn commit: r831088 - in /hadoop/zookeeper/trunk: CHANGES.txt
src/c/src/zookeeper.c src/c/tests/TestOperations.cc
Author: mahadev
Date: Thu Oct 29 21:04:44 2009
New Revision: 831088
URL: http://svn.apache.org/viewvc?rev=831088&view=rev
Log:
ZOOKEEPER-562. c client can flood server with pings if tcp send queue filled. (ben reed via mahadev)
Modified:
hadoop/zookeeper/trunk/CHANGES.txt
hadoop/zookeeper/trunk/src/c/src/zookeeper.c
hadoop/zookeeper/trunk/src/c/tests/TestOperations.cc
Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=831088&r1=831087&r2=831088&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Thu Oct 29 21:04:44 2009
@@ -97,6 +97,9 @@
ZOOKEEPER-563. ant test for recipes is broken. (mahadev via phunt)
+ ZOOKEEPER-562. c client can flood server with pings if tcp send queue
+ filled. (ben reed via mahadev)
+
IMPROVEMENTS:
ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to
"socket reuse" and failure to close client (phunt via mahadev)
Modified: hadoop/zookeeper/trunk/src/c/src/zookeeper.c
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/src/zookeeper.c?rev=831088&r1=831087&r2=831088&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/c/src/zookeeper.c (original)
+++ hadoop/zookeeper/trunk/src/c/src/zookeeper.c Thu Oct 29 21:04:44 2009
@@ -1402,7 +1402,7 @@
// a PING
if (zh->state==ZOO_CONNECTED_STATE) {
send_to = zh->recv_timeout/3 - idle_send;
- if (send_to <= 0) {
+ if (send_to <= 0 && zh->sent_requests.head==0) {
// LOG_DEBUG(("Sending PING to %s (exceeded idle by %dms)",
// format_current_endpoint_info(zh),-send_to));
int rc=send_ping(zh);
Modified: hadoop/zookeeper/trunk/src/c/tests/TestOperations.cc
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/tests/TestOperations.cc?rev=831088&r1=831087&r2=831088&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/c/tests/TestOperations.cc (original)
+++ hadoop/zookeeper/trunk/src/c/tests/TestOperations.cc Thu Oct 29 21:04:44 2009
@@ -279,6 +279,27 @@
// only one ping so far?
CPPUNIT_ASSERT_EQUAL(1,zkServer.pingCount_);
CPPUNIT_ASSERT(timeMock==zh->last_recv);
+
+ // Round 4
+ // make sure that a ping is not sent if something is outstanding
+ AsyncGetOperationCompletion res1;
+ rc=zoo_aget(zh,"/x/y/1",0,asyncCompletion,&res1);
+ CPPUNIT_ASSERT_EQUAL((int)ZOK,rc);
+ rc=zookeeper_interest(zh,&fd,&interest,&tv);
+ CPPUNIT_ASSERT_EQUAL((int)ZOK,rc);
+ timeMock.tick(tv);
+ rc=zookeeper_interest(zh,&fd,&interest,&tv);
+ CPPUNIT_ASSERT_EQUAL((int)ZOK,rc);
+ rc=zookeeper_process(zh,interest);
+ CPPUNIT_ASSERT_EQUAL((int)ZNOTHING,rc);
+ rc=zookeeper_interest(zh,&fd,&interest,&tv);
+ CPPUNIT_ASSERT_EQUAL((int)ZOK,rc);
+ // pseudo-sleep for a short while (10 ms)
+ timeMock.millitick(10);
+ rc=zookeeper_process(zh,interest);
+ CPPUNIT_ASSERT_EQUAL((int)ZNOTHING,rc);
+ // only one ping so far?
+ CPPUNIT_ASSERT_EQUAL(1,zkServer.pingCount_);
}
// simulate a watch arriving right before a ping is due
@@ -346,6 +367,7 @@
// queue up a request; keep it pending (as if the server is busy or has died)
AsyncGetOperationCompletion res1;
+ zkServer.addOperationResponse(new ZooGetResponse("2",1));
int rc=zoo_aget(zh,"/x/y/1",0,asyncCompletion,&res1);
int fd=0;
@@ -358,7 +380,7 @@
CPPUNIT_ASSERT_EQUAL((int)ZOK,rc);
// no delay -- the socket is writable
rc=zookeeper_process(zh,interest);
- CPPUNIT_ASSERT_EQUAL((int)ZNOTHING,rc); // ZNOTHING -- no response yet
+ CPPUNIT_ASSERT_EQUAL((int)ZOK,rc);
// Round 2.
// what's next?