File: 05-ZOOKEEPER-770.patch

package info (click to toggle)
zookeeper 3.9.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,872 kB
  • sloc: java: 122,772; cpp: 14,071; ansic: 12,468; javascript: 11,754; xml: 4,965; python: 2,829; sh: 2,444; makefile: 241; perl: 114
file content (76 lines) | stat: -rw-r--r-- 2,438 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Description: Slow add_auth calls with multi-threaded client
Origin: https://issues.apache.org/jira/browse/ZOOKEEPER-770

--- a/zookeeper-client/zookeeper-client-c/tests/TestClient.cc
+++ b/zookeeper-client/zookeeper-client-c/tests/TestClient.cc
@@ -195,6 +195,20 @@
 
 } watchctx_t;
 
+static inline int calculate_interval(const struct timeval *start,
+         const struct timeval *end)
+{
+    int interval;
+    struct timeval i = *end;
+    i.tv_sec -= start->tv_sec;
+    i.tv_usec -= start->tv_usec;
+    interval = i.tv_sec * 1000 + (i.tv_usec/1000);
+    return interval;
+}
+
+static timeval completion_timestamp;
+
+
 class Zookeeper_simpleSystem : public CPPUNIT_NS::TestFixture
 {
     CPPUNIT_TEST_SUITE(Zookeeper_simpleSystem);
@@ -584,6 +598,14 @@
         count++;
     }
 
+
+    static void voidCompletionWithTimestamp(int rc, const void *data) {
+        int tmp = (int) (long) data;
+        CPPUNIT_ASSERT_EQUAL(tmp, rc);
+        gettimeofday(&completion_timestamp, 0);
+        count++;
+    }
+
     static void verifyCreateFails(const char *path, zhandle_t *zk) {
       CPPUNIT_ASSERT_EQUAL((int)ZBADARGUMENTS, zoo_create(zk,
           path, "", 0, &ZOO_OPEN_ACL_UNSAFE, 0, 0, 0));
@@ -671,6 +693,8 @@
         zhandle_t *zk = createClient(&ctx1);
         struct ACL_vector nodeAcl;
         struct ACL acl_val;
+        struct timeval started;
+
         rc = zoo_add_auth(0, "", 0, 0, voidCompletion, (void*)-1);
         CPPUNIT_ASSERT_EQUAL((int) ZBADARGUMENTS, rc);
 
@@ -704,11 +728,13 @@
         //create a new client
         zk = createClient(&ctx2);
 
-        rc = zoo_add_auth(zk, "digest", "pat:passwd2", 11, voidCompletion,
+        gettimeofday(&started, 0);
+        rc = zoo_add_auth(zk, "digest", "pat:passwd2", 11, voidCompletionWithTimestamp,
                           (void*)ZOK);
         CPPUNIT_ASSERT_EQUAL((int) ZOK, rc);
         waitForVoidCompletion(3);
         CPPUNIT_ASSERT(count == 0);
+        CPPUNIT_ASSERT(calculate_interval(&started, &completion_timestamp) < 2);
 
         char buf[1024];
         int blen = sizeof(buf);
--- a/zookeeper-client/zookeeper-client-c/src/zookeeper.c
+++ b/zookeeper-client/zookeeper-client-c/src/zookeeper.c
@@ -2103,7 +2103,7 @@
     /* We queued the buffer, so don't free it */
     close_buffer_oarchive(&oa, 0);
 
-    return rc;
+    return rc<0 ? rc : adaptor_send_queue(zh, 0);
 }
 
 /** send all auths, not just the last one **/