Fixes a bug in lease action when grpc timeout is set (#204)

Signed-off-by: Tao He <sighingnow@gmail.com>
This commit is contained in:
Tao He 2023-03-14 20:37:34 +08:00 committed by GitHub
parent 5e27ac33c6
commit 9fc0f37ef7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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");
} }
} }