summaryrefslogtreecommitdiff
path: root/content/llcache.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/llcache.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/llcache.c')
-rw-r--r--content/llcache.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/content/llcache.c b/content/llcache.c
index 154f7c4a4..98c3d72e2 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -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;
}