Fixes a bug in lease action when grpc timeout is set

Signed-off-by: Tao He <sighingnow@gmail.com>
This commit is contained in:
Tao He 2023-03-14 19:06:00 +08:00
parent d27f0b9e81
commit 3ae4e290a5
1 changed files with 4 additions and 4 deletions

View File

@ -146,14 +146,14 @@ etcd::Response etcdv3::AsyncLeaseKeepAliveAction::Refresh()
break; break;
} }
case CompletionQueue::NextStatus::GOT_EVENT: { case CompletionQueue::NextStatus::GOT_EVENT: {
if (!ok || got_tag != (void *)etcdv3::KEEPALIVE_READ) { if (ok && got_tag == (void *)etcdv3::KEEPALIVE_READ) {
return etcd::Response(grpc::StatusCode::ABORTED, "Failed to create a lease keep-alive connection: read not ok or invalid tag"); return etcd::Response(ParseResponse(), etcd::detail::duration_till_now(start_timepoint));
} }
break; break;
} }
} }
this->CancelKeepAlive(); this->CancelKeepAlive();
return etcd::Response(ParseResponse(), etcd::detail::duration_till_now(start_timepoint)); return etcd::Response(grpc::StatusCode::ABORTED, "Failed to create a lease keep-alive connection: read not ok or invalid tag");
} else { } else {
stream->Write(leasekeepalive_request, (void *)etcdv3::KEEPALIVE_WRITE); stream->Write(leasekeepalive_request, (void *)etcdv3::KEEPALIVE_WRITE);
// wait write finish // wait write finish
@ -165,7 +165,7 @@ etcd::Response etcdv3::AsyncLeaseKeepAliveAction::Refresh()
} }
} }
this->CancelKeepAlive(); this->CancelKeepAlive();
return etcd::Response(grpc::StatusCode::ABORTED, "Failed to create a lease keep-alive connection"); return etcd::Response(grpc::StatusCode::ABORTED, "Failed to create a lease keep-alive connection: read not ok or invalid tag");
} }
} }