Rate-limit cache clean attempts

svn path=/trunk/netsurf/; revision=10686
This commit is contained in:
John Mark Bell 2010-08-10 19:58:39 +00:00
parent 696a71c80d
commit 48b17a5aea
2 changed files with 29 additions and 5 deletions

View File

@ -29,8 +29,9 @@
#include "utils/http.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/url.h"
#include "utils/ring.h"
#include "utils/url.h"
#include "utils/utils.h"
typedef struct hlcache_entry hlcache_entry;
typedef struct hlcache_retrieval_ctx hlcache_retrieval_ctx;
@ -151,10 +152,22 @@ void hlcache_finalise(void)
/* See hlcache.h for documentation */
nserror hlcache_poll(void)
{
static uint32_t last_clean_time;
uint32_t now;
llcache_poll();
/* Give the cache a clean */
hlcache_clean();
/* Only attempt to clean the cache every 5 seconds */
#define HLCACHE_CLEAN_INTERVAL_CS (500)
now = wallclock();
if (now > last_clean_time + HLCACHE_CLEAN_INTERVAL_CS) {
/* Give the cache a clean */
hlcache_clean();
last_clean_time = now;
}
#undef HLCACHE_CLEAN_INTERVAL_CS
return NSERROR_OK;
}

View File

@ -269,6 +269,8 @@ void llcache_finalise(void)
/* See llcache.h for documentation */
nserror llcache_poll(void)
{
static uint32_t last_clean_time;
uint32_t now;
llcache_object *object;
fetch_poll();
@ -284,8 +286,17 @@ nserror llcache_poll(void)
llcache_object_notify_users(object);
}
/* Attempt to clean the cache */
llcache_clean();
/* Only attempt to clean the cache every 5 seconds */
#define LLCACHE_CLEAN_INTERVAL_CS (500)
now = wallclock();
if (now > last_clean_time + LLCACHE_CLEAN_INTERVAL_CS) {
/* Attempt to clean the cache */
llcache_clean();
last_clean_time = now;
}
#undef LLCACHE_CLEAN_INTERVAL_CS
return NSERROR_OK;
}