SharedPV.close() call onLastDisconnect()

ensure that onLastDisconnect() is called when
the channels list becomes empty (edge), and
not afterwards.
This commit is contained in:
Michael Davidsaver
2018-08-29 16:19:34 +02:00
parent 9ec0172520
commit 3bc1603f47
2 changed files with 11 additions and 3 deletions

View File

@@ -225,6 +225,7 @@ void SharedPV::close(bool destroy)
xrpcs_t p_rpc;
xmonitors_t p_monitor;
xchannels_t p_channel;
Handler::shared_pointer p_handler;
{
Guard I(mutex);
@@ -259,7 +260,10 @@ void SharedPV::close(bool destroy)
puts.clear();
rpcs.clear();
monitors.clear();
bool wasempty = channels.empty();
channels.clear();
if(!wasempty && channels.empty())
p_handler = handler;
}
}
FOR_EACH(xputs_t::iterator, it, end, p_put) {
@@ -276,6 +280,10 @@ void SharedPV::close(bool destroy)
if(!req) continue;
req->channelStateChange(*it, destroy ? pva::Channel::DESTROYED : pva::Channel::DISCONNECTED);
}
if(p_handler) {
shared_pointer self(internal_self);
p_handler->onLastDisconnect(self);
}
}
pvd::PVStructure::shared_pointer SharedPV::build()