Return-Path: Delivered-To: apmail-hadoop-zookeeper-commits-archive@minotaur.apache.org Received: (qmail 47320 invoked from network); 12 Mar 2009 00:49:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Mar 2009 00:49:09 -0000 Received: (qmail 64143 invoked by uid 500); 12 Mar 2009 00:49:09 -0000 Delivered-To: apmail-hadoop-zookeeper-commits-archive@hadoop.apache.org Received: (qmail 64116 invoked by uid 500); 12 Mar 2009 00:49:09 -0000 Mailing-List: contact zookeeper-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: zookeeper-dev@ Delivered-To: mailing list zookeeper-commits@hadoop.apache.org Received: (qmail 64105 invoked by uid 99); 12 Mar 2009 00:49:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Mar 2009 17:49:09 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Mar 2009 00:49:08 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3B45923888A5; Thu, 12 Mar 2009 00:48:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r752730 - in /hadoop/zookeeper/trunk: CHANGES.txt src/c/src/zookeeper.c src/c/tests/TestClient.cc Date: Thu, 12 Mar 2009 00:48:48 -0000 To: zookeeper-commits@hadoop.apache.org From: phunt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090312004848.3B45923888A5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: phunt Date: Thu Mar 12 00:48:47 2009 New Revision: 752730 URL: http://svn.apache.org/viewvc?rev=752730&view=rev Log: ZOOKEEPER-309. core dump using zoo_get_acl() 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=752730&r1=752729&r2=752730&view=diff ============================================================================== --- hadoop/zookeeper/trunk/CHANGES.txt (original) +++ hadoop/zookeeper/trunk/CHANGES.txt Thu Mar 12 00:48:47 2009 @@ -28,6 +28,8 @@ ZOOKEEPER-333. helgrind thread issues identified in mt c client code (mahadev via phunt) + + ZOOKEEPER-309. core dump using zoo_get_acl() (mahadev via phunt) IMPROVEMENTS: ZOOKEEPER-308. improve the atomic broadcast performance 3x. Modified: hadoop/zookeeper/trunk/src/c/src/zookeeper.c URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/src/zookeeper.c?rev=752730&r1=752729&r2=752730&view=diff ============================================================================== --- hadoop/zookeeper/trunk/src/c/src/zookeeper.c (original) +++ hadoop/zookeeper/trunk/src/c/src/zookeeper.c Thu Mar 12 00:48:47 2009 @@ -1680,7 +1680,6 @@ if (rc == 0) { struct GetACLResponse res; deserialize_GetACLResponse(ia, "reply", &res); - cptr->c.acl_result(rc, &res.acl, &res.stat, cptr->data); sc->u.acl.acl = res.acl; sc->u.acl.stat = res.stat; /* We don't deallocate since we are passing it back */ Modified: hadoop/zookeeper/trunk/src/c/tests/TestClient.cc URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/tests/TestClient.cc?rev=752730&r1=752729&r2=752730&view=diff ============================================================================== --- hadoop/zookeeper/trunk/src/c/tests/TestClient.cc (original) +++ hadoop/zookeeper/trunk/src/c/tests/TestClient.cc Thu Mar 12 00:48:47 2009 @@ -159,6 +159,7 @@ #ifdef THREADED CPPUNIT_TEST(testPathValidation); CPPUNIT_TEST(testPing); + CPPUNIT_TEST(testAcl); CPPUNIT_TEST(testWatcherAutoResetWithGlobal); CPPUNIT_TEST(testWatcherAutoResetWithLocal); #endif @@ -222,7 +223,7 @@ sprintf(cmd, "%s stop %s", ZKSERVER_CMD, getHostPorts()); CPPUNIT_ASSERT(system(cmd) == 0); } - + void testPing() { watchctx_t ctxIdle; @@ -296,6 +297,53 @@ path, "", 0, &ZOO_OPEN_ACL_UNSAFE, 0, 0, 0)); } + + /** + returns false if the vectors dont match + **/ + bool compareAcl(struct ACL_vector acl1, struct ACL_vector acl2) { + if (acl1.count != acl2.count) { + return false; + } + struct ACL *aclval1 = acl1.data; + struct ACL *aclval2 = acl2.data; + if (aclval1->perms != aclval2->perms) { + return false; + } + struct Id id1 = aclval1->id; + struct Id id2 = aclval2->id; + if (strcmp(id1.scheme, id2.scheme) != 0) { + return false; + } + if (strcmp(id1.id, id2.id) != 0) { + return false; + } + return true; + } + + void testAcl() { + int rc; + struct String_vector strings; + struct ACL_vector aclvec; + struct Stat stat; + watchctx_t ctx; + zhandle_t *zk = createClient(&ctx); + rc = zoo_create(zk, "/acl", "", 0, + &ZOO_OPEN_ACL_UNSAFE, 0, 0, 0); + CPPUNIT_ASSERT_EQUAL((int)ZOK, rc); + rc = zoo_get_acl(zk, "/acl", &aclvec, &stat ); + CPPUNIT_ASSERT_EQUAL((int) ZOK, rc); + bool cmp = compareAcl(ZOO_OPEN_ACL_UNSAFE, aclvec); + CPPUNIT_ASSERT_EQUAL(true, cmp); + rc = zoo_set_acl(zk, "/acl", -1, &ZOO_READ_ACL_UNSAFE); + CPPUNIT_ASSERT_EQUAL((int) ZOK, rc); + rc = zoo_get_acl(zk, "/acl", &aclvec, &stat); + CPPUNIT_ASSERT_EQUAL((int) ZOK, rc); + cmp = compareAcl(ZOO_READ_ACL_UNSAFE, aclvec); + CPPUNIT_ASSERT_EQUAL(true, cmp); + } + + void testPathValidation() { watchctx_t ctx; zhandle_t *zk = createClient(&ctx); @@ -376,7 +424,7 @@ rc = zoo_acreate(zk, path, "", 0, &ZOO_OPEN_ACL_UNSAFE, 0, stringCompletion, strdup(path)); CPPUNIT_ASSERT_EQUAL((int)ZOK, rc); } - + yield(zk, 1); stopServer(); CPPUNIT_ASSERT(ctx.waitForDisconnected(zk)); @@ -409,6 +457,7 @@ rc = zoo_create(zk, "/watchtest/child", "", 0, &ZOO_OPEN_ACL_UNSAFE, ZOO_EPHEMERAL, 0, 0); CPPUNIT_ASSERT_EQUAL((int)ZOK, rc); + if (isGlobal) { testName = "GlobalTest"; rc = zoo_get_children(zk, "/watchtest", 1, &strings);