Signed-off-by: Tao He <sighingnow@gmail.com>
This commit is contained in:
Tao He 2021-09-23 14:14:45 +08:00
parent 895857c523
commit ea0557dd6d
1 changed files with 19 additions and 12 deletions

View File

@ -74,6 +74,7 @@ void etcdv3::AsyncWatchAction::waitForResponse()
if (reply.canceled()) { if (reply.canceled()) {
isCancelled.store(true); isCancelled.store(true);
cq_.Shutdown(); cq_.Shutdown();
break;
} }
else if ((reply.created() && reply.header().revision() < parameters.revision) || else if ((reply.created() && reply.header().revision() < parameters.revision) ||
reply.events_size() > 0) { reply.events_size() > 0) {
@ -92,11 +93,14 @@ void etcdv3::AsyncWatchAction::waitForResponse()
grpc::Status status; grpc::Status status;
stream->Finish(&status, (void *)this); stream->Finish(&status, (void *)this);
if (cq_.Next(&got_tag, &ok) && ok && got_tag == (void *)this) {
// ok // n.b., don't wait, as there might be another extra "Read" action on the fly.
} else { //
std::cerr << "WARN: Failed to finish a watch connection" << std::endl; // if (cq_.Next(&got_tag, &ok) && ok && got_tag == (void *)this) {
} // // ok
// } else {
// std::cerr << "WARN: Failed to finish a watch connection" << std::endl;
// }
cq_.Shutdown(); cq_.Shutdown();
@ -104,6 +108,7 @@ void etcdv3::AsyncWatchAction::waitForResponse()
if (reply.fragment()) { if (reply.fragment()) {
std::cerr << "WARN: The response hasn't been fully received and parsed" << std::endl; std::cerr << "WARN: The response hasn't been fully received and parsed" << std::endl;
} }
break;
} }
else else
{ {
@ -130,11 +135,13 @@ void etcdv3::AsyncWatchAction::CancelWatch()
grpc::Status status; grpc::Status status;
stream->Finish(&status, (void *)this); stream->Finish(&status, (void *)this);
if (cq_.Next(&got_tag, &ok) && ok && got_tag == (void *)this) { // n.b., don't wait, as there might be another extra "Read" action on the fly.
// ok //
} else { // if (cq_.Next(&got_tag, &ok) && ok && got_tag == (void *)this) {
std::cerr << "WARN: Failed to finish a watch connection" << std::endl; // // ok
} // } else {
// std::cerr << "WARN: Failed to finish a watch connection" << std::endl;
// }
cq_.Shutdown(); cq_.Shutdown();
} }