mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-01 01:16:55 +02:00
#3074: Fix sessions may not return back to the pool
This commit is contained in:
parent
c512a69f3e
commit
6d7fafd6f1
@ -233,28 +233,43 @@ void SessionPool::putBack(PooledSessionHolderPtr pHolder)
|
||||
SessionList::iterator it = std::find(_activeSessions.begin(), _activeSessions.end(), pHolder);
|
||||
if (it != _activeSessions.end())
|
||||
{
|
||||
if (pHolder->session()->isGood())
|
||||
try
|
||||
{
|
||||
pHolder->session()->reset();
|
||||
if (pHolder->session()->isGood())
|
||||
{
|
||||
pHolder->session()->reset();
|
||||
|
||||
// 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);
|
||||
// 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);
|
||||
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());
|
||||
// re-apply the default pool settings
|
||||
applySettings(pHolder->session());
|
||||
|
||||
pHolder->access();
|
||||
_idleSessions.push_front(pHolder);
|
||||
pHolder->access();
|
||||
_idleSessions.push_front(pHolder);
|
||||
}
|
||||
else --_nSessions;
|
||||
|
||||
_activeSessions.erase(it);
|
||||
}
|
||||
catch (const Poco::Exception& e)
|
||||
{
|
||||
--_nSessions;
|
||||
_activeSessions.erase(it);
|
||||
poco_bugcheck_msg(format("Exception in SessionPool::putBack(): %s", e.displayText()).c_str());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
--_nSessions;
|
||||
_activeSessions.erase(it);
|
||||
poco_bugcheck_msg("Unknown exception in SessionPool::putBack()");
|
||||
}
|
||||
else --_nSessions;
|
||||
|
||||
_activeSessions.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -273,8 +288,13 @@ void SessionPool::onJanitorTimer(Poco::Timer&)
|
||||
{
|
||||
if ((*it)->idle() > _idleTime || !(*it)->session()->isGood())
|
||||
{
|
||||
try { (*it)->session()->close(); }
|
||||
catch (...) { }
|
||||
try
|
||||
{
|
||||
(*it)->session()->close();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
it = _idleSessions.erase(it);
|
||||
--_nSessions;
|
||||
}
|
||||
@ -299,8 +319,13 @@ void SessionPool::closeAll(SessionList& sessionList)
|
||||
SessionList::iterator it = sessionList.begin();
|
||||
for (; it != sessionList.end();)
|
||||
{
|
||||
try { (*it)->session()->close(); }
|
||||
catch (...) { }
|
||||
try
|
||||
{
|
||||
(*it)->session()->close();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
it = sessionList.erase(it);
|
||||
if (_nSessions > 0) --_nSessions;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user