Github user rgs1 commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/90#discussion_r88183747
  
    --- Diff: src/c/src/zookeeper.c ---
    @@ -4052,6 +3958,76 @@ int zoo_amulti(zhandle_t *zh, int count, const 
zoo_op_t *ops,
         return (rc < 0) ? ZMARSHALLINGERROR : ZOK;
     }
     
    +
    +int zoo_aremove_watchers(zhandle_t *zh, const char *path, ZooWatcherType 
wtype,
    +        watcher_fn watcher, void *watcherCtx, int local,
    +        void_completion_t *completion, const void *data)
    +{
    +    char *server_path = prepend_string(zh, path);
    +    int rc;
    +    struct oarchive *oa;
    +    struct RequestHeader h = { get_xid(), ZOO_REMOVE_WATCHES };
    +    struct RemoveWatchesRequest req =  { (char*)server_path, wtype };
    +    watcher_deregistration_t *wdo;
    +
    +    if (!zh || !isValidPath(server_path, 0)) {
    +        rc = ZBADARGUMENTS;
    +        goto done;
    +    }
    +
    +    if (!local && is_unrecoverable(zh)) {
    +        rc = ZINVALIDSTATE;
    +        goto done;
    +    }
    +
    +    if (!pathHasWatcher(zh, server_path, wtype, watcher, watcherCtx)) {
    +        rc = ZNOWATCHER;
    +        goto done;
    +    }
    +
    +    if (local) {
    +        removeWatchers(zh, server_path, wtype, watcher, watcherCtx);
    +#ifdef THREADED
    +        notify_sync_completion((struct sync_completion *)data);
    --- End diff --
    
    @breed @fpj btw -- sorry for the confusing code. `zoo_aremove_watchers` is 
sui generis given that it's the only public method that can return `ZOK` 
without scheduling a remote call (for which then, the callback would be 
naturally dispatched). Thus, this horrible hack of calling 
`notify_sync_completion()`. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to