zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] phunt commented on a change in pull request #831: ZOOKEEPER-3286: xid wrap-around causes connection loss/segfault when hitting predefined XIDs
Date Wed, 13 Mar 2019 04:25:57 GMT
phunt commented on a change in pull request #831: ZOOKEEPER-3286: xid wrap-around causes connection
loss/segfault when hitting predefined XIDs
URL: https://github.com/apache/zookeeper/pull/831#discussion_r264970714
 
 

 ##########
 File path: zookeeper-client/zookeeper-client-c/src/st_adaptor.c
 ##########
 @@ -77,11 +77,11 @@ int32_t inc_ref_counter(zhandle_t* zh,int i)
 
 int32_t get_xid()
 {
-    static int32_t xid = -1;
-    if (xid == -1) {
-        xid = time(0);
-    }
-    return xid++;
+    static int32_t xid = 1;
+
+    // The XID returned should not be negative to avoid collisions
+    // with reserved XIDs, such as AUTH_XID or SET_WATCHES_XID.
+    return xid++ & ~(1<<31);
 
 Review comment:
   The obscurity over-weights the benefits to me... (a/b earlier)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message