summaryrefslogtreecommitdiff
path: root/content/hlcache.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2010-08-10 19:58:39 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2010-08-10 19:58:39 +0000
commit48b17a5aea05ce997f72cd6a43d7cf12f419306d (patch)
treed3a5f3a6a9ecd23963c251ff88bd986d691faabd /content/hlcache.c
parent696a71c80d93af7cbb8eab027864b9937ab07a86 (diff)
downloadnetsurf-48b17a5aea05ce997f72cd6a43d7cf12f419306d.tar.gz
netsurf-48b17a5aea05ce997f72cd6a43d7cf12f419306d.tar.bz2
Rate-limit cache clean attempts
svn path=/trunk/netsurf/; revision=10686
Diffstat (limited to 'content/hlcache.c')
-rw-r--r--content/hlcache.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/content/hlcache.c b/content/hlcache.c
index 1fd6fe4ad..7dc82a42d 100644
--- a/content/hlcache.c
+++ b/content/hlcache.c
@@ -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;
}