This is an automated email from the ASF dual-hosted git repository.

huijun pushed a commit to branch huijunw/reorderzkclientdestructor
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git

commit c0b3856adc79eddd21d5903efb9aa4f31292d80a
Author: Huijun Wu <[email protected]>
AuthorDate: Wed May 23 15:07:11 2018 -0700

    reorder
---
 heron/common/src/cpp/zookeeper/zkclient.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/heron/common/src/cpp/zookeeper/zkclient.cpp 
b/heron/common/src/cpp/zookeeper/zkclient.cpp
index c9750e4..f200d42 100644
--- a/heron/common/src/cpp/zookeeper/zkclient.cpp
+++ b/heron/common/src/cpp/zookeeper/zkclient.cpp
@@ -146,8 +146,12 @@ void ZKClient::Init() {
 
 // Destructor.
 ZKClient::~ZKClient() {
-  delete piper_;
   zookeeper_close(zk_handle_);
+  // zookeeper_close() depends on piper_
+  // when HeronZKStateMgr::GlobalWatchEventHandler() and GetCompletionWatcher
+  // are called at the same time in two threads,
+  // thus `delete piper_` after zookeeper_close() joins all zk_client threads.
+  delete piper_;
 }
 
 //

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to