more SharedPV::close()
This commit is contained in:
@@ -143,6 +143,10 @@ public:
|
||||
//! If destory=true, the internal client list is cleared.
|
||||
//! @post In the closed state
|
||||
//! @note Provider locking rules apply (@see provider_roles_requester_locking).
|
||||
//!
|
||||
//! close() is not final, even with destroy=true new clients may begin connecting, and open() may be called again.
|
||||
//! A final close() should be performed after the removal from StaticProvider/DynamicProvider
|
||||
//! which will prevent new clients.
|
||||
virtual void close(bool destroy=false);
|
||||
|
||||
//! Create a new container which may be used to prepare to call post().
|
||||
|
||||
@@ -51,7 +51,7 @@ SharedChannel::SharedChannel(const std::tr1::shared_ptr<SharedPV> &owner,
|
||||
if(owner->channels.empty())
|
||||
handler = owner->handler;
|
||||
owner->channels.push_back(this);
|
||||
owner->notifiedConn = !!handler;
|
||||
owner->notifiedConn = true;
|
||||
}
|
||||
if(handler) {
|
||||
handler->onFirstConnect(owner);
|
||||
|
||||
@@ -231,35 +231,36 @@ void SharedPV::close(bool destroy)
|
||||
{
|
||||
Guard I(mutex);
|
||||
|
||||
if(!type)
|
||||
return;
|
||||
if(type) {
|
||||
|
||||
p_put.reserve(puts.size());
|
||||
p_rpc.reserve(rpcs.size());
|
||||
p_monitor.reserve(monitors.size());
|
||||
p_channel.reserve(channels.size());
|
||||
p_put.reserve(puts.size());
|
||||
p_rpc.reserve(rpcs.size());
|
||||
p_monitor.reserve(monitors.size());
|
||||
p_channel.reserve(channels.size());
|
||||
|
||||
FOR_EACH(puts_t::const_iterator, it, end, puts) {
|
||||
(*it)->mapper.reset();
|
||||
p_put.push_back((*it)->requester.lock());
|
||||
}
|
||||
FOR_EACH(rpcs_t::const_iterator, it, end, rpcs) {
|
||||
p_rpc.push_back((*it)->requester.lock());
|
||||
}
|
||||
FOR_EACH(monitors_t::const_iterator, it, end, monitors) {
|
||||
(*it)->close();
|
||||
try {
|
||||
p_monitor.push_back((*it)->shared_from_this());
|
||||
}catch(std::tr1::bad_weak_ptr&) { /* ignore, racing dtor */ }
|
||||
}
|
||||
FOR_EACH(channels_t::const_iterator, it, end, channels) {
|
||||
try {
|
||||
p_channel.push_back((*it)->shared_from_this());
|
||||
}catch(std::tr1::bad_weak_ptr&) { /* ignore, racing dtor */ }
|
||||
FOR_EACH(puts_t::const_iterator, it, end, puts) {
|
||||
(*it)->mapper.reset();
|
||||
p_put.push_back((*it)->requester.lock());
|
||||
}
|
||||
FOR_EACH(rpcs_t::const_iterator, it, end, rpcs) {
|
||||
p_rpc.push_back((*it)->requester.lock());
|
||||
}
|
||||
FOR_EACH(monitors_t::const_iterator, it, end, monitors) {
|
||||
(*it)->close();
|
||||
try {
|
||||
p_monitor.push_back((*it)->shared_from_this());
|
||||
}catch(std::tr1::bad_weak_ptr&) { /* ignore, racing dtor */ }
|
||||
}
|
||||
FOR_EACH(channels_t::const_iterator, it, end, channels) {
|
||||
try {
|
||||
p_channel.push_back((*it)->shared_from_this());
|
||||
}catch(std::tr1::bad_weak_ptr&) { /* ignore, racing dtor */ }
|
||||
}
|
||||
|
||||
type.reset();
|
||||
current.reset();
|
||||
}
|
||||
|
||||
type.reset();
|
||||
current.reset();
|
||||
if(destroy) {
|
||||
// forget about all clients, to prevent the possibility of our
|
||||
// sending a second destroy notification.
|
||||
|
||||
Reference in New Issue
Block a user