SharedPV.close() call onLastDisconnect()
ensure that onLastDisconnect() is called when the channels list becomes empty (edge), and not afterwards.
This commit is contained in:
@ -62,9 +62,9 @@ SharedChannel::~SharedChannel()
|
||||
std::tr1::shared_ptr<SharedPV::Handler> handler;
|
||||
{
|
||||
Guard G(owner->mutex);
|
||||
bool wasempty = owner->channels.empty();
|
||||
owner->channels.remove(this);
|
||||
if(owner->channels.empty()) {
|
||||
Guard G(owner->mutex);
|
||||
if(!wasempty && owner->channels.empty()) {
|
||||
handler = owner->handler;
|
||||
}
|
||||
}
|
||||
@ -74,7 +74,7 @@ SharedChannel::~SharedChannel()
|
||||
if(owner->debugLvl>5)
|
||||
{
|
||||
pva::ChannelRequester::shared_pointer req(requester.lock());
|
||||
errlogPrintf("%s : Open channel to %s > %p\n",
|
||||
errlogPrintf("%s : Close channel to %s > %p\n",
|
||||
req ? req->getRequesterName().c_str() : "<Defunct>",
|
||||
channelName.c_str(),
|
||||
this);
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user