You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by ma...@apache.org on 2011/09/14 06:09:18 UTC
svn commit: r1170430 - in /zookeeper/trunk: CHANGES.txt src/c/src/zookeeper.c
Author: mahadev
Date: Wed Sep 14 04:09:18 2011
New Revision: 1170430
URL: http://svn.apache.org/viewvc?rev=1170430&view=rev
Log:
ZOOKEEPER-981. Hang in zookeeper_close() in the multi-threaded C client. (Jeremy Stribling via mahadev)
Modified:
zookeeper/trunk/CHANGES.txt
zookeeper/trunk/src/c/src/zookeeper.c
Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1170430&r1=1170429&r2=1170430&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Wed Sep 14 04:09:18 2011
@@ -313,7 +313,10 @@ BUGFIXES:
ZOOKEEPER-731. Zookeeper#delete , #create - async versions miss a verb in the javadoc. (Thomas Koch via camille)
ZOOKEEPER-1108. Various bugs in zoo_add_auth in C. (Dheeraj Agrawal via mahadev)
-
+
+ ZOOKEEPER-981. Hang in zookeeper_close() in the multi-threaded C client.
+ (Jeremy Stribling via mahadev)
+
IMPROVEMENTS:
ZOOKEEPER-724. Improve junit test integration - log harness information
(phunt via mahadev)
Modified: zookeeper/trunk/src/c/src/zookeeper.c
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/src/zookeeper.c?rev=1170430&r1=1170429&r2=1170430&view=diff
==============================================================================
--- zookeeper/trunk/src/c/src/zookeeper.c (original)
+++ zookeeper/trunk/src/c/src/zookeeper.c Wed Sep 14 04:09:18 2011
@@ -2471,15 +2471,24 @@ int zookeeper_close(zhandle_t *zh)
return ZBADARGUMENTS;
zh->close_requested=1;
- if (inc_ref_counter(zh,0)!=0) {
+ if (inc_ref_counter(zh,1)>1) {
+ /* We have incremented the ref counter to prevent the
+ * completions from calling zookeeper_close before we have
+ * completed the adaptor_finish call below. */
+
/* Signal any syncronous completions before joining the threads */
enter_critical(zh);
free_completions(zh,1,ZCLOSING);
leave_critical(zh);
adaptor_finish(zh);
+ /* Now we can allow the handle to be cleaned up, if the completion
+ * threads finished during the adaptor_finish call. */
+ api_epilog(zh, 0);
return ZOK;
}
+ /* No need to decrement the counter since we're just going to
+ * destroy the handle later. */
if(zh->state==ZOO_CONNECTED_STATE){
struct oarchive *oa;
struct RequestHeader h = { STRUCT_INITIALIZER (xid , get_xid()), STRUCT_INITIALIZER (type , ZOO_CLOSE_OP)};