zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shuxin Yang <shuxinyang....@gmail.com>
Subject why not disable sync API in libzkst.a?
Date Tue, 07 May 2019 06:15:44 GMT
Hi,

     I'm new to C API lib. I accidentally use single-thread lib (i.e. 
libzkst.a) and it took me quit a while before I realize all sync 
functions in the libzkst.a is not usable at all. I'm wondering why not 
just disable them in libztst.a. It would otherwise be pretty confusing 
and error-prone.

    Take zoo_get_children() as an example, it always return ZOK, and 0 
children.  This function in turn calls zoo_wget_children_() which is 
excerpted bellow. The wait_sync_completion() at line 3657 actually does 
nothing in the single-thread version, meaning this function simply 
return to the caller without waiting for the job done.

Thanks

Shuxin


--------------------------------------------------------------

3646 static int zoo_wget_children_(...)

3650     struct sync_completion *sc = alloc_sync_completion();

....

3655     rc= zoo_awget_children (zh, path, watcher, watcherCtx, 
SYNCHRONOUS_MARKER, sc);
3656 if(rc==ZOK){
3657 wait_sync_completion(sc);
3658         rc = sc->rc;
3659         if (rc == 0) {
3660             if (strings) {
3661                 *strings = sc->u.strs2;
3662             } else {
3663 deallocate_String_vector(&sc->u.strs2);
3664 }
3665 }
3666 }
3667 free_sync_completion(sc);
3668     return rc;
3669 }

----------------------------------------------------------------



Mime
View raw message