diff options
author | Yuchen Zeng <zyc@google.com> | 2017-09-05 13:32:44 -0700 |
---|---|---|
committer | Yuchen Zeng <zyc@google.com> | 2017-09-05 13:32:44 -0700 |
commit | 26b0a34fbef7ab43870f51a1971ea4578e211ac3 (patch) | |
tree | c0836b87f41cf6fc60f57d8c3d374a4bbe043feb | |
parent | 5150cbd02d5a5d7cec64fa46225f2bb38611ba3b (diff) |
Address review comments
-rw-r--r-- | src/cpp/client/channel_cc.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc index bad36a0b8c..19a25c838f 100644 --- a/src/cpp/client/channel_cc.cc +++ b/src/cpp/client/channel_cc.cc @@ -195,8 +195,8 @@ class ChannelConnectivityWatcher : private GrpcLibraryCodegen { int channel_count_; std::mutex shutdown_mu_; - std::condition_variable shutdown_cv_; // protected by shutdown_cv_ - bool shutdown_; // protected by shutdown_cv_ + std::condition_variable shutdown_cv_; // protected by shutdown_mu_ + bool shutdown_; // protected by shutdown_mu_ static std::mutex g_watcher_mu_; static ChannelConnectivityWatcher* g_watcher_; // protected by g_watcher_mu_ @@ -222,11 +222,11 @@ Channel::Channel(const grpc::string& host, grpc_channel* channel) } Channel::~Channel() { - if (grpc_channel_support_connectivity_watcher(c_channel_)) { - grpc_channel_destroy(c_channel_); + const bool stop_watching = + grpc_channel_support_connectivity_watcher(c_channel_); + grpc_channel_destroy(c_channel_); + if (stop_watching) { ChannelConnectivityWatcher::StopWatching(); - } else { - grpc_channel_destroy(c_channel_); } } |