From b9e59338516484ea97c6d1551ef3e54ada84f46d Mon Sep 17 00:00:00 2001 From: Tao He Date: Sun, 5 Mar 2023 21:29:07 +0800 Subject: [PATCH] Fixes Signed-off-by: Tao He --- src/v3/AsyncWatchAction.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/v3/AsyncWatchAction.cpp b/src/v3/AsyncWatchAction.cpp index 62685c3..06e6ea2 100644 --- a/src/v3/AsyncWatchAction.cpp +++ b/src/v3/AsyncWatchAction.cpp @@ -98,11 +98,17 @@ void etcdv3::AsyncWatchAction::waitForResponse() std::cerr << "WARN: The response hasn't been fully received and parsed" << std::endl; } + std::cout << "issue a watch cancel" << std::endl; + // cancel the watcher after receiving the good response this->CancelWatch(); - continue; + + // start the next round to read finish messages, read into "&dummy" + // (use nullptr, as it won't be touched). + stream->Read(nullptr, (void*)etcdv3::WATCH_FINISH); + } else { + // start the next round to read reply, read into "&reply" + stream->Read(&reply, (void*)this); } - // otherwise, start next round read-reply - stream->Read(&reply, (void*)this); continue; } if(isCancelled.load()) {