fixed GH #2738: Poco::AccessExpireStrategy::onGet() must not extend expiration time after expiration

This commit is contained in:
Günter Obiltschnig
2019-07-01 17:51:38 +02:00
parent 4c3351ea05
commit 12897d3d63
5 changed files with 44 additions and 9 deletions

View File

@@ -31,7 +31,7 @@
namespace Poco {
template <
template <
class TKey,
class TValue
>
@@ -55,11 +55,14 @@ public:
typename ExpireStrategy<TKey, TValue>::Iterator it = this->_keys.find(key);
if (it != this->_keys.end())
{
this->_keyIndex.erase(it->second);
Timestamp now;
typename ExpireStrategy<TKey, TValue>::IndexIterator itIdx =
this->_keyIndex.insert(typename ExpireStrategy<TKey, TValue>::TimeIndex::value_type(now, key));
it->second = itIdx;
if (!it->second->first.isElapsed(this->_expireTime)) // don't extend if already expired
{
this->_keyIndex.erase(it->second);
Timestamp now;
typename ExpireStrategy<TKey, TValue>::IndexIterator itIdx =
this->_keyIndex.insert(typename ExpireStrategy<TKey, TValue>::TimeIndex::value_type(now, key));
it->second = itIdx;
}
}
}
};