Author: jmb
Date: Tue Aug 10 14:58:39 2010
New Revision: 10686
URL:
http://source.netsurf-browser.org?rev=10686&view=rev
Log:
Rate-limit cache clean attempts
Modified:
trunk/netsurf/content/hlcache.c
trunk/netsurf/content/llcache.c
Modified: trunk/netsurf/content/hlcache.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/content/hlcache.c?rev=106...
==============================================================================
--- trunk/netsurf/content/hlcache.c (original)
+++ trunk/netsurf/content/hlcache.c Tue Aug 10 14:58:39 2010
@@ -29,8 +29,9 @@
#include "utils/http.h"
#include "utils/log.h"
#include "utils/messages.h"
+#include "utils/ring.h"
#include "utils/url.h"
-#include "utils/ring.h"
+#include "utils/utils.h"
typedef struct hlcache_entry hlcache_entry;
typedef struct hlcache_retrieval_ctx hlcache_retrieval_ctx;
@@ -151,10 +152,22 @@
/* 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;
}
Modified: trunk/netsurf/content/llcache.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/content/llcache.c?rev=106...
==============================================================================
--- trunk/netsurf/content/llcache.c (original)
+++ trunk/netsurf/content/llcache.c Tue Aug 10 14:58:39 2010
@@ -269,6 +269,8 @@
/* 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 @@
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;
}