void MulticastClientTransport::dropIdleTransports() { bringInNewTransports(); Lock lock(mClientTransportsMutex); bool needToRemove = false; ClientTransportList::iterator iter; for (iter = mClientTransports.begin(); iter != mClientTransports.end(); ++iter) { RCF::ClientTransport & transport = ***iter; RcfSessionWeakPtr rcfSessionWeakPtr = transport.getRcfSession(); if ( rcfSessionWeakPtr == RcfSessionWeakPtr() ) { // HTTP/HTTPS connections do not hold on to the RcfSession and can't receive pings. continue; } RcfSessionPtr rcfSessionPtr = rcfSessionWeakPtr.lock(); if (!rcfSessionPtr) { RCF_LOG_2() << "Dropping subscription. Subscriber has closed connection."; iter->reset(); needToRemove = true; } else { boost::uint32_t pingIntervalMs = rcfSessionPtr->getPingIntervalMs(); if (pingIntervalMs) { RCF::Timer pingTimer( rcfSessionPtr->getPingTimestamp() ); if (pingTimer.elapsed(5000 + 2*pingIntervalMs)) { std::string subscriberUrl = rcfSessionPtr->getClientAddress().string(); RCF_LOG_2()(subscriberUrl)(pingIntervalMs) << "Dropping subscription. Subscriber has not sent pings within the expected ping interval."; iter->reset(); needToRemove = true; } } } } if (needToRemove) { eraseRemove(mClientTransports, ClientTransportAutoPtrPtr()); } }
void MulticastClientTransport::pingAllTransports() { bringInNewTransports(); Lock lock(mClientTransportsMutex); if (!mMulticastTemp.get()) { mMulticastTemp.reset( new MulticastClientTransport() ); } MulticastClientTransport & multicastTemp = static_cast<MulticastClientTransport &>(*mMulticastTemp); multicastTemp.mClientTransports.resize(0); ClientTransportList::iterator iter; for (iter = mClientTransports.begin(); iter != mClientTransports.end(); ++iter) { I_ClientTransport & transport = ***iter; RcfSessionPtr rcfSessionPtr = transport.getRcfSession().lock(); if (rcfSessionPtr) { boost::uint32_t pingIntervalMs = rcfSessionPtr->getPingIntervalMs(); if (pingIntervalMs) { multicastTemp.mClientTransports.push_back(*iter); } } } RcfClient<I_Null> nullClient( mMulticastTemp ); nullClient.getClientStub().ping(RCF::Oneway); mMulticastTemp.reset( nullClient.getClientStub().releaseTransport().release() ); multicastTemp.mClientTransports.resize(0); }