Repository navigation
Conversation
…eport false success Fix a group of related defects in the C client watch removal APIs: - In the multithreaded library, a local removal with zoo_aremove_watches() or zoo_aremove_all_watches() cast the caller's data pointer to a sync completion and signaled it. This wrote mutex state into application memory and could hang in pthread_mutex_lock. aremove_watches() no longer signals a sync completion. A local removal is complete when the call returns, so the synchronous wrapper waits only for removals that go to the server. A local removal does not call the completion, as before. The header now documents this. - zoo_aremove_watches() and zoo_aremove_all_watches() declared the completion as void_completion_t *, a pointer to a function pointer. Correct callers failed to compile in C++ and with GCC 14. Declare it as void_completion_t. The ABI does not change. - containsWatcher() matched a NULL watcher before it looked up the path. A local removal of all watches returned ZOK for a path with no watches. Return ZNOWATCHER, as the header documents and as the Java client does. Add the real-server test Zookeeper_simpleSystem::testAsyncRemoveWatchers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oveWatchers testRemoveWatchers stops the server and does not start it again. It was the last test in Zookeeper_simpleSystem, so this did not matter before. testAsyncRemoveWatchers now runs after it and failed with ZCONNECTIONLOSS in the full suite. Start the server again at the end of testRemoveWatchers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anmolnar
left a comment
There was a problem hiding this comment.
AI-assisted review on behalf of @anmolnar
Thanks for this. I traced all three fixes against zookeeper.c, zk_hashtable.c and mt_adaptor.c and they look correct to me. The new ZNOWATCHER behaviour matches ZKWatchManager.contains in the Java client. I did not build or run the cppunit suite.
A few points, none blocking:
-
Local async removal never calls the completion. With
local != 0,zoo_aremove_watches/zoo_aremove_all_watchesreturn ZOK and the completion never runs. The header now says so, but this is the onlyzoo_a*call with that contract. The Java client always sends the request and invokes the callback, and useslocalonly as a fallback when the server call fails. Could\param localalso be reworded to say that the server is not contacted? And do you think queuing the completion with ZOK on the local path is worth a follow-up JIRA? -
Non-local remove-all now short-circuits on the client. With the
containsWatcherchange,zoo_remove_all_watches(..., local=0)on a path with no local watchers returns ZNOWATCHER without a round trip. I think that is the right result, but the commit message only mentions the local case. One side effect: a server-side watch left behind by an earlier local removal can no longer be cleared this way. -
Signature change.
void_completion_t *→void_completion_tis correct and ABI-neutral. C callers who added a(void_completion_t *)cast to silence the old warning will stop compiling cleanly, so a release-note line would help, especially if this is backported. -
testRemoveWatchersleaks its second handle. Now that the server is restarted at the end, that handle reconnects and lives throughtestAsyncRemoveWatchers, which shares the staticcount. Azookeeper_close(zk)before the finalstartServer()would be cleaner.
Fix a group of related defects in the C client watch removal APIs:
zoo_aremove_watches()orzoo_aremove_all_watches()cast the caller's data pointer to a sync completion and signaled it. This writes mutex state into application memory and can hang inpthread_mutex_lock. After the fixaremove_watches()no longer signals a sync completion. A local removal is complete when the call returns, so the synchronous wrapper waits only for removals that go to the server. A local removal does not call the completion, as before. The header documents these semantics.zoo_aremove_watches()andzoo_aremove_all_watches()declared the completion asvoid_completion_t *, a pointer to a function pointer. Correct callers failed to compile in C++ and with GCC 14. The fix declare its asvoid_completion_t. The ABI does not change.containsWatcher()matched aNULLwatcher before it looked up the path. A local removal of all watches returnedZOKfor a path with no watches. The fix is to returnZNOWATCHER, as the header mentions and as the Java client does.Adds the test
Zookeeper_simpleSystem::testAsyncRemoveWatchers.