Fixes the deadlock in keep alive
Signed-off-by: Tao He <sighingnow@gmail.com>
This commit is contained in:
parent
81d446e55c
commit
32b18f9022
|
|
@ -62,7 +62,7 @@ namespace etcdv3
|
||||||
|
|
||||||
LeaseKeepAliveRequest req;
|
LeaseKeepAliveRequest req;
|
||||||
bool isCancelled;
|
bool isCancelled;
|
||||||
std::mutex protect_is_cancelled;
|
std::recursive_mutex protect_is_cancelled;
|
||||||
|
|
||||||
friend class etcd::KeepAlive;
|
friend class etcd::KeepAlive;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ etcdv3::AsyncLeaseKeepAliveResponse etcdv3::AsyncLeaseKeepAliveAction::ParseResp
|
||||||
|
|
||||||
etcd::Response etcdv3::AsyncLeaseKeepAliveAction::Refresh()
|
etcd::Response etcdv3::AsyncLeaseKeepAliveAction::Refresh()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> scope_lock(this->protect_is_cancelled);
|
std::lock_guard<std::recursive_mutex> scope_lock(this->protect_is_cancelled);
|
||||||
|
|
||||||
auto start_timepoint = std::chrono::high_resolution_clock::now();
|
auto start_timepoint = std::chrono::high_resolution_clock::now();
|
||||||
if (isCancelled) {
|
if (isCancelled) {
|
||||||
|
|
@ -171,7 +171,7 @@ etcd::Response etcdv3::AsyncLeaseKeepAliveAction::Refresh()
|
||||||
|
|
||||||
void etcdv3::AsyncLeaseKeepAliveAction::CancelKeepAlive()
|
void etcdv3::AsyncLeaseKeepAliveAction::CancelKeepAlive()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> scope_lock(this->protect_is_cancelled);
|
std::lock_guard<std::recursive_mutex> scope_lock(this->protect_is_cancelled);
|
||||||
if(isCancelled == false)
|
if(isCancelled == false)
|
||||||
{
|
{
|
||||||
isCancelled = true;
|
isCancelled = true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue