zookeeper icon indicating copy to clipboard operation
zookeeper copied to clipboard

ZOOKEEPER-3286: xid wrap-around causes connection loss/segfault when hitting predefined XIDs

Open ccma14 opened this issue 6 years ago • 2 comments

I just saw ZOOKEEPER-3253, which seems to fix the issue for the Java client. This fixes the issue for the C client, by avoiding returning negative XIDs.

ccma14 avatar Feb 22 '19 21:02 ccma14

Regarding an automated test case:

In the C client the XID counter is stored in a static variable within the scope of the get_xid function in st_adapter.c/mt_adapter.c, which makes writing a test case a little harder than for the Java case, because you can't set the initial value for the XID counter from outside that function.

In order to be able to write a test case similar to what we have for Java would require moving the static XID counter to the library's global scope and making it accessible/settable from outside the library, which we probably don't want for regular use cases of the library.

However, if that's acceptable I can modify the patch and cook up a unit test...

ccma14 avatar Feb 22 '19 21:02 ccma14

The code looks good to me.

As for the unit test, making the counter global strikes me as overkill too but I'll let someone who represents the project make the actual decision.

enixon avatar Mar 06 '19 18:03 enixon