mirror of https://github.com/aria2/aria2
2010-10-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Remove expired cookies first when cookies_ is full. * src/CookieStorage.ccpull/1/head
parent
0abd4a2f7b
commit
bcddb4cfa3
|
@ -1,3 +1,8 @@
|
||||||
|
2010-10-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Remove expired cookies first when cookies_ is full.
|
||||||
|
* src/CookieStorage.cc
|
||||||
|
|
||||||
2010-10-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-10-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Rewritten util::split()
|
Rewritten util::split()
|
||||||
|
|
|
@ -70,13 +70,21 @@ bool CookieStorage::DomainEntry::addCookie(const Cookie& cookie, time_t now)
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if(cookies_.size() >= CookieStorage::MAX_COOKIE_PER_DOMAIN) {
|
if(cookies_.size() >= CookieStorage::MAX_COOKIE_PER_DOMAIN) {
|
||||||
// TODO First remove expired cookie
|
cookies_.erase
|
||||||
|
(std::remove_if(cookies_.begin(), cookies_.end(),
|
||||||
|
std::bind2nd
|
||||||
|
(std::mem_fun_ref(&Cookie::isExpired), now)),
|
||||||
|
cookies_.end());
|
||||||
|
if(cookies_.size() >= CookieStorage::MAX_COOKIE_PER_DOMAIN) {
|
||||||
std::deque<Cookie>::iterator m = std::min_element
|
std::deque<Cookie>::iterator m = std::min_element
|
||||||
(cookies_.begin(), cookies_.end(), LeastRecentAccess<Cookie>());
|
(cookies_.begin(), cookies_.end(), LeastRecentAccess<Cookie>());
|
||||||
*m = cookie;
|
*m = cookie;
|
||||||
} else {
|
} else {
|
||||||
cookies_.push_back(cookie);
|
cookies_.push_back(cookie);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
cookies_.push_back(cookie);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if(cookie.isExpired(now)) {
|
} else if(cookie.isExpired(now)) {
|
||||||
|
@ -113,8 +121,6 @@ static const double DOMAIN_EVICTION_RATE = 0.1;
|
||||||
bool CookieStorage::store(const Cookie& cookie, time_t now)
|
bool CookieStorage::store(const Cookie& cookie, time_t now)
|
||||||
{
|
{
|
||||||
if(domains_.size() >= DOMAIN_EVICTION_TRIGGER) {
|
if(domains_.size() >= DOMAIN_EVICTION_TRIGGER) {
|
||||||
// TODO Do this in a separete Command.
|
|
||||||
// TODO Erase expired cookie first
|
|
||||||
std::sort(domains_.begin(), domains_.end(),
|
std::sort(domains_.begin(), domains_.end(),
|
||||||
LeastRecentAccess<DomainEntry>());
|
LeastRecentAccess<DomainEntry>());
|
||||||
size_t delnum = (size_t)(domains_.size()*DOMAIN_EVICTION_RATE);
|
size_t delnum = (size_t)(domains_.size()*DOMAIN_EVICTION_RATE);
|
||||||
|
|
Loading…
Reference in New Issue