hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1026159 - in /hadoop/zookeeper/trunk: CHANGES.txt src/c/src/zookeeper.c src/c/tests/TestClient.cc
Date Thu, 21 Oct 2010 22:12:51 GMT
Author: mahadev
Date: Thu Oct 21 22:12:50 2010
New Revision: 1026159

URL: http://svn.apache.org/viewvc?rev=1026159&view=rev
Log:
ZOOKEEPER-800. zoo_add_auth returns ZOK if zookeeper handle is in ZOO_CLOSED_STATE (michi
mutsuzaki via mahadev konar)

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/c/src/zookeeper.c
    hadoop/zookeeper/trunk/src/c/tests/TestClient.cc

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=1026159&r1=1026158&r2=1026159&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Thu Oct 21 22:12:50 2010
@@ -134,6 +134,9 @@ BUGFIXES: 
   ZOOKEEPER-794. Callbacks are not invoked when the client is closed
   (Alexis Midon via phunt)
 
+  ZOOKEEPER-800. zoo_add_auth returns ZOK if zookeeper handle is in
+  ZOO_CLOSED_STATE (michi mutsuzaki via mahadev konar)
+
 IMPROVEMENTS:
   ZOOKEEPER-724. Improve junit test integration - log harness information 
   (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=1026159&r1=1026158&r2=1026159&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/c/src/zookeeper.c (original)
+++ hadoop/zookeeper/trunk/src/c/src/zookeeper.c Thu Oct 21 22:12:50 2010
@@ -2934,6 +2934,12 @@ int zoo_add_auth(zhandle_t *zh,const cha
     if (is_unrecoverable(zh))
         return ZINVALIDSTATE;
 
+    // [ZOOKEEPER-800] zoo_add_auth should return ZINVALIDSTATE if
+    // the connection is closed. 
+    if (zoo_state(zh) == 0) {
+        return ZINVALIDSTATE;
+    }
+
     if(cert!=NULL && certLen!=0){
         auth.buff=calloc(1,certLen);
         if(auth.buff==0) {

Modified: hadoop/zookeeper/trunk/src/c/tests/TestClient.cc
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/tests/TestClient.cc?rev=1026159&r1=1026158&r2=1026159&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/c/tests/TestClient.cc (original)
+++ hadoop/zookeeper/trunk/src/c/tests/TestClient.cc Thu Oct 21 22:12:50 2010
@@ -591,6 +591,15 @@ public:
 
         rc = zoo_set_acl(zk, "/", -1, &ZOO_OPEN_ACL_UNSAFE);
         CPPUNIT_ASSERT_EQUAL((int) ZOK, rc);
+
+        // [ZOOKEEPER-800] zoo_add_auth should return ZINVALIDSTATE if
+        // the connection is closed. 
+        zhandle_t *zk2 = zookeeper_init(hostPorts, NULL, 10000, 0, NULL, 0);
+        sleep(1);
+        CPPUNIT_ASSERT_EQUAL((int) ZOK, zookeeper_close(zk2));
+        CPPUNIT_ASSERT_EQUAL(0, zoo_state(zk2)); // 0 ==> ZOO_CLOSED_STATE
+        rc = zoo_add_auth(zk2, "digest", "pat:passwd", 10, voidCompletion, (void*)ZOK);
+        CPPUNIT_ASSERT_EQUAL((int) ZINVALIDSTATE, rc);
     }
 
     void testGetChildren2() {



Mime
View raw message