예제 #1
0
void SessionPool::putBack(PooledSessionHolderPtr pHolder)
{
	Poco::Mutex::ScopedLock lock(_mutex);
	if (_shutdown) return;

	for (SessionList::iterator it = _activeSessions.begin(); it != _activeSessions.end(); ++it)
	{
		if ((*it)->session == pHolder)
		{
			if (pHolder->session()->isConnected())
			{
				// reverse settings applied at acquisition time, if any
				AddPropertyMap::iterator pIt = _addPropertyMap.find(pHolder->session());
				if (pIt != _addPropertyMap.end())
					pHolder->session()->setProperty(pIt->second.first, pIt->second.second);

				AddFeatureMap::iterator fIt = _addFeatureMap.find(pHolder->session());
				if (fIt != _addFeatureMap.end())
					pHolder->session()->setFeature(fIt->second.first, fIt->second.second);

				// re-apply the default pool settings
				applySettings(pHolder->session());
			
				pHolder->access();
				_idleSessions.push_front(std::move(*it));
			}
			else
			{
				--_nSessions;
			};
			_activeSessions.erase(it);
			break;
		}
	}
}
예제 #2
0
void SessionPool::putBack(PooledSessionHolderPtr pHolder)
{
	Poco::Mutex::ScopedLock lock(_mutex);
	if (_shutdown) return;

	SessionList::iterator it = std::find(_activeSessions.begin(), _activeSessions.end(), pHolder);
	if (it != _activeSessions.end())
	{
		if (pHolder->session()->isConnected())
		{
			// reverse settings applied at acquisition time, if any
			AddPropertyMap::iterator pIt = _addPropertyMap.find(pHolder->session());
			if (pIt != _addPropertyMap.end())
				pHolder->session()->setProperty(pIt->second.first, pIt->second.second);

			AddFeatureMap::iterator fIt = _addFeatureMap.find(pHolder->session());
			if (fIt != _addFeatureMap.end())
				pHolder->session()->setFeature(fIt->second.first, fIt->second.second);

			// re-apply the default pool settings
			applySettings(pHolder->session());

			pHolder->access();
			_idleSessions.push_front(pHolder);
		}
		else --_nSessions;

		_activeSessions.erase(it);
	}
	else
	{
		poco_bugcheck_msg("Unknown session passed to SessionPool::putBack()");
	}
}
예제 #3
0
void SessionPool::putBack(PooledSessionHolderPtr pHolder)
{
	Poco::FastMutex::ScopedLock lock(_mutex);
	
	SessionList::iterator it = std::find(_activeSessions.begin(), _activeSessions.end(), pHolder);
	if (it != _activeSessions.end())
	{
		if (pHolder->session()->isConnected())
		{
			pHolder->access();
			_idleSessions.push_front(pHolder);
		}
		else --_nSessions;

		_activeSessions.erase(it);
	}
	else
	{
		poco_bugcheck_msg("Unknown session passed to SessionPool::putBack()");
	}
}