zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1166970 - in /zookeeper/trunk: ./ src/c/src/ src/c/tests/ src/java/main/org/apache/zookeeper/
Date Fri, 09 Sep 2011 02:27:20 GMT
Author: mahadev
Date: Fri Sep  9 02:27:19 2011
New Revision: 1166970

URL: http://svn.apache.org/viewvc?rev=1166970&view=rev
Log:
ZOOKEEPER-1108. Various bugs in zoo_add_auth in C. (Dheeraj Agrawal via mahadev)

Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/src/c/src/zk_adaptor.h
    zookeeper/trunk/src/c/src/zookeeper.c
    zookeeper/trunk/src/c/tests/TestClient.cc
    zookeeper/trunk/src/c/tests/TestZookeeperInit.cc
    zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxn.java
    zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1166970&r1=1166969&r2=1166970&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Fri Sep  9 02:27:19 2011
@@ -311,6 +311,8 @@ BUGFIXES: 
   ZOOKEEPER-1160. test timeouts are too small (breed via phunt)
 
   ZOOKEEPER-731. Zookeeper#delete , #create - async versions miss a verb in the javadoc.
(Thomas Koch via camille)
+
+  ZOOKEEPER-1108. Various bugs in zoo_add_auth in C. (Dheeraj Agrawal via mahadev)
   
 IMPROVEMENTS:
   ZOOKEEPER-724. Improve junit test integration - log harness information 

Modified: zookeeper/trunk/src/c/src/zk_adaptor.h
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/src/zk_adaptor.h?rev=1166970&r1=1166969&r2=1166970&view=diff
==============================================================================
--- zookeeper/trunk/src/c/src/zk_adaptor.h (original)
+++ zookeeper/trunk/src/c/src/zk_adaptor.h Fri Sep  9 02:27:19 2011
@@ -41,6 +41,7 @@
 #define CONNECTING_STATE_DEF 1
 #define ASSOCIATING_STATE_DEF 2
 #define CONNECTED_STATE_DEF 3
+#define NOTCONNECTED_STATE_DEF 999
 
 /* zookeeper event type constants */
 #define CREATED_EVENT_DEF 1

Modified: zookeeper/trunk/src/c/src/zookeeper.c
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/src/zookeeper.c?rev=1166970&r1=1166969&r2=1166970&view=diff
==============================================================================
--- zookeeper/trunk/src/c/src/zookeeper.c (original)
+++ zookeeper/trunk/src/c/src/zookeeper.c Fri Sep  9 02:27:19 2011
@@ -334,7 +334,7 @@ static void mark_active_auth(zhandle_t *
         return;
     }
     element = auth_h.auth;
-    while (element->next != NULL) {
+    while (element != NULL) {
         element->state = 1;
         element = element->next;
     }
@@ -784,7 +784,7 @@ zhandle_t *zookeeper_init(const char *ho
         return 0;
     }
     zh->fd = -1;
-    zh->state = 0;
+    zh->state = NOTCONNECTED_STATE_DEF;
     zh->context = context;
     zh->recv_timeout = recv_timeout;
     init_auth_info(&zh->auth_h);
@@ -1318,7 +1318,7 @@ static int send_auth_info(zhandle_t *zh)
         zoo_unlock_auth(zh);
         return ZOK;
     }
-    while (auth->next != NULL) {
+    while (auth != NULL) {
         rc = send_info_packet(zh, auth);
         auth = auth->next;
     }

Modified: zookeeper/trunk/src/c/tests/TestClient.cc
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/tests/TestClient.cc?rev=1166970&r1=1166969&r2=1166970&view=diff
==============================================================================
--- zookeeper/trunk/src/c/tests/TestClient.cc (original)
+++ zookeeper/trunk/src/c/tests/TestClient.cc Fri Sep  9 02:27:19 2011
@@ -518,7 +518,6 @@ public:
                           (void*)ZOK);
         CPPUNIT_ASSERT_EQUAL((int) ZOK, rc);
         waitForVoidCompletion(3);
-
         CPPUNIT_ASSERT(count == 0);
 
         rc = zoo_create(zk, "/tauth1", "", 0, &ZOO_CREATOR_ALL_ACL, 0, 0, 0);
@@ -592,6 +591,16 @@ public:
         rc = zoo_set_acl(zk, "/", -1, &ZOO_OPEN_ACL_UNSAFE);
         CPPUNIT_ASSERT_EQUAL((int) ZOK, rc);
 
+        //[ZOOKEEPER-1108], test that auth info is sent to server, if client is not
+        //connected to server when zoo_add_auth was called.
+        zhandle_t *zk_auth = zookeeper_init(hostPorts, NULL, 10000, 0, NULL, 0);
+        rc = zoo_add_auth(zk_auth, "digest", "pat:passwd", 10, voidCompletion, (void*)ZOK);
+        CPPUNIT_ASSERT_EQUAL((int) ZOK, rc);
+        sleep(2);
+        CPPUNIT_ASSERT(count == 1);
+        count  = 0;
+        CPPUNIT_ASSERT_EQUAL((int) ZOK, zookeeper_close(zk_auth));
+        
         // [ZOOKEEPER-800] zoo_add_auth should return ZINVALIDSTATE if
         // the connection is closed. 
         zhandle_t *zk2 = zookeeper_init(hostPorts, NULL, 10000, 0, NULL, 0);

Modified: zookeeper/trunk/src/c/tests/TestZookeeperInit.cc
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/tests/TestZookeeperInit.cc?rev=1166970&r1=1166969&r2=1166970&view=diff
==============================================================================
--- zookeeper/trunk/src/c/tests/TestZookeeperInit.cc (original)
+++ zookeeper/trunk/src/c/tests/TestZookeeperInit.cc Fri Sep  9 02:27:19 2011
@@ -106,7 +106,7 @@ public:
         CPPUNIT_ASSERT(zh->hostname!=0);
         CPPUNIT_ASSERT_EQUAL(EXPECTED_ADDRS_COUNT,zh->addrs_count);
         CPPUNIT_ASSERT_EQUAL(EXPECTED_HOST,string(zh->hostname));
-        CPPUNIT_ASSERT(zh->state == 0);
+        CPPUNIT_ASSERT(zh->state == NOTCONNECTED_STATE_DEF);
         CPPUNIT_ASSERT(zh->context == (void*)1);
         CPPUNIT_ASSERT_EQUAL(EXPECTED_RECV_TIMEOUT,zh->recv_timeout);
         CPPUNIT_ASSERT(zh->watcher == watcher);

Modified: zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxn.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxn.java?rev=1166970&r1=1166969&r2=1166970&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxn.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxn.java Fri Sep  9 02:27:19
2011
@@ -1204,7 +1204,7 @@ public class ClientCnxn {
 
     private int xid = 1;
 
-    private volatile States state;
+    private volatile States state = States.NOT_CONNECTED;
 
     synchronized private int getXid() {
         return xid++;

Modified: zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java?rev=1166970&r1=1166969&r2=1166970&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java Fri Sep  9 02:27:19
2011
@@ -310,7 +310,7 @@ public class ZooKeeper {
 
     public enum States {
         CONNECTING, ASSOCIATING, CONNECTED, CONNECTEDREADONLY,
-        CLOSED, AUTH_FAILED;
+        CLOSED, AUTH_FAILED, NOT_CONNECTED;
 
         public boolean isAlive() {
             return this != CLOSED && this != AUTH_FAILED;



Mime
View raw message