zkutil: Probably fixed crashing on ZK connection loss. [#METR-10202]

This commit is contained in:
Michael Kolupaev 2014-04-08 14:13:49 +04:00
parent 63cff6a5a4
commit e0d2bce6e2

View File

@ -13,10 +13,20 @@ typedef std::promise<WatchEventInfo> WatchPromise;
struct WatchWithPromise : public zk::Watch
{
WatchPromise promise;
bool notified;
WatchWithPromise() : notified(false) {}
void process(WatchEvent::type event, SessionState::type state, const std::string & path)
{
if (notified)
{
LOG_WARNING(&Logger::get("WatchWithPromise"), "Ignoring event " << WatchEvent::toString(event) << " with state "
<< SessionState::toString(state) << " for path " << path);
return;
}
promise.set_value(WatchEventInfo(event, state, path));
notified = true;
}
};