提交 87f7e0b3 编写于 作者: A alesapin

More compatible watches in TestKeeper

上级 e88c2c70
......@@ -511,19 +511,30 @@ void TestKeeper::processingThread()
if (expired)
break;
if (info.watch)
{
auto & watches_type = dynamic_cast<const ListRequest *>(info.request.get())
? list_watches
: watches;
watches_type[info.request->getPath()].emplace_back(std::move(info.watch));
}
++zxid;
info.request->addRootPath(root_path);
auto [response, _] = info.request->process(container, zxid);
if (info.watch)
{
/// To be compatible with real ZooKeeper we add watch if request was successful (i.e. node exists)
/// or if it was exists request which allows to add watches for non existing nodes.
if (response->error == Error::ZOK)
{
auto & watches_type = dynamic_cast<const ListRequest *>(info.request.get())
? list_watches
: watches;
watches_type[info.request->getPath()].emplace_back(std::move(info.watch));
}
else if (response->error == Error::ZNONODE && dynamic_cast<const ExistsRequest *>(info.request.get()))
{
watches[info.request->getPath()].emplace_back(std::move(info.watch));
}
}
if (response->error == Error::ZOK)
info.request->processWatches(watches, list_watches);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册