summaryrefslogtreecommitdiff
path: root/content/llcache.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-04-30 14:28:18 +0100
committerVincent Sanders <vince@kyllikki.org>2015-04-30 14:28:18 +0100
commit2aef095f27e55600f6cbdf6f3d4c4f1fe584f07b (patch)
tree41851788a2ab2c7db2162f6d5702c4e080c8eb40 /content/llcache.c
parent05538c0264db8ba117248f481e769f62969dc82b (diff)
downloadnetsurf-2aef095f27e55600f6cbdf6f3d4c4f1fe584f07b.tar.gz
netsurf-2aef095f27e55600f6cbdf6f3d4c4f1fe584f07b.tar.bz2
Ensure bandwidth minimum check is only performed when enough data has
been written.
Diffstat (limited to 'content/llcache.c')
-rw-r--r--content/llcache.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/content/llcache.c b/content/llcache.c
index 2267f8f8f..9628fd348 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -2427,17 +2427,26 @@ write_backing_store(struct llcache_object *object,
* If the overall write bandwidth has fallen below a useful level for
* the backing store to be effective disable it.
*
+ * It is important to ensure a useful amount of data has been written
+ * before calculating bandwidths otherwise tiny files taking a
+ * disproportionately long time to write might trigger this erroneously.
+ *
* \param p The context pointer passed to the callback.
*/
static void llcache_persist_slowcheck(void *p)
{
- unsigned long total_bandwidth; /* total bandwidth */
- total_bandwidth = (llcache->total_written * 1000) / llcache->total_elapsed;
+ uint64_t total_bandwidth; /* total bandwidth */
+
+ if (llcache->total_written > (2 * llcache->minimum_bandwidth)) {
- if (total_bandwidth < llcache->minimum_bandwidth) {
- LOG(("Cannot write minimum bandwidth"));
- warn_user("LowDiscWriteBandwidth", 0);
- guit->llcache->finalise();
+ total_bandwidth = (llcache->total_written * 1000) / llcache->total_elapsed;
+
+ if (total_bandwidth < llcache->minimum_bandwidth) {
+ LOG(("Current bandwidth %llu less than minimum %llu",
+ total_bandwidth, llcache->minimum_bandwidth));
+ warn_user("LowDiscWriteBandwidth", 0);
+ guit->llcache->finalise();
+ }
}
}