summaryrefslogtreecommitdiff
path: root/content/llcache.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-12-01 11:32:33 +0000
committerVincent Sanders <vince@kyllikki.org>2014-12-01 11:32:33 +0000
commitc9ee49baa8bbf39bfe1ee619b7c9810a1e4f3256 (patch)
treef08ec561120576dabdcb54a183ceaae9686ac6c1 /content/llcache.c
parentba5ade87b2fe5a3c4a4153f0d5a8f73eb04048aa (diff)
downloadnetsurf-c9ee49baa8bbf39bfe1ee619b7c9810a1e4f3256.tar.gz
netsurf-c9ee49baa8bbf39bfe1ee619b7c9810a1e4f3256.tar.bz2
cope with backing store writeout making no progress
Diffstat (limited to 'content/llcache.c')
-rw-r--r--content/llcache.c96
1 files changed, 52 insertions, 44 deletions
diff --git a/content/llcache.c b/content/llcache.c
index e12273ee1..e80085aff 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -2411,63 +2411,71 @@ static void llcache_persist(void *p)
/* obtained a candidate list, make each object persistant in turn */
for (idx = 0; idx < lst_count; idx++) {
ret = write_backing_store(lst[idx], &written, &elapsed);
- if (ret == NSERROR_OK) {
- /* sucessfully wrote object to backing store */
- total_written += written;
- total_elapsed += elapsed;
- total_bandwidth = (total_written * 1000) / total_elapsed;
- LOG(("Wrote %d bytes in %dms bw:%d %s",
- written, elapsed, (written * 1000) / elapsed,
- nsurl_access(lst[idx]->url) ));
-
- /* check to for the time quantum or the size
- * (bandwidth) for this run being exceeded.
- */
- if (total_elapsed > llcache->time_quantum) {
- LOG(("Overran timeslot"));
- /* writeout has exhausted the available time.
- * Either the writeout is slow or the last
- * object was very large.
- */
- if (total_bandwidth < llcache->minimum_bandwidth) {
- LOG(("Cannot write minimum bandwidth"));
- warn_user("Disc cache write bandwidth is too slow to be useful, disabling cache", 0);
- guit->llcache->finalise();
- break;
- } else {
- if (total_bandwidth > llcache->maximum_bandwidth) {
- /* fast writeout of large file
- * so calculate delay as if
- * write happened only at max
- * limit
- */
- next = ((total_written * llcache->time_quantum) / write_limit) - total_elapsed;
- } else {
- next = llcache->time_quantum;
- }
- break;
- }
- } else if (total_written > write_limit) {
- /* The bandwidth limit has been reached. */
+ if (ret != NSERROR_OK) {
+ continue;
+ }
+ /* sucessfully wrote object to backing store */
+ total_written += written;
+ total_elapsed += elapsed;
+ total_bandwidth = (total_written * 1000) / total_elapsed;
+ LOG(("Wrote %d bytes in %dms bw:%d %s",
+ written, elapsed, (written * 1000) / elapsed,
+ nsurl_access(lst[idx]->url) ));
+
+ /* check to for the time quantum or the size
+ * (bandwidth) for this run being exceeded.
+ */
+ if (total_elapsed > llcache->time_quantum) {
+ LOG(("Overran timeslot"));
+ /* writeout has exhausted the available time.
+ * Either the writeout is slow or the last
+ * object was very large.
+ */
+ if (total_bandwidth < llcache->minimum_bandwidth) {
+ LOG(("Cannot write minimum bandwidth"));
+ warn_user("Disc cache write bandwidth is too slow to be useful, disabling cache", 0);
+ guit->llcache->finalise();
+ break;
+ } else {
if (total_bandwidth > llcache->maximum_bandwidth) {
- /* fast writeout of large file so
- * calculate delay as if write
- * happened only at max limit
+ /* fast writeout of large file
+ * so calculate delay as if
+ * write happened only at max
+ * limit
*/
next = ((total_written * llcache->time_quantum) / write_limit) - total_elapsed;
} else {
- next = llcache->time_quantum - total_elapsed;
+ next = llcache->time_quantum;
}
break;
}
+ } else if (total_written > write_limit) {
+ /* The bandwidth limit has been reached. */
+
+ if (total_bandwidth > llcache->maximum_bandwidth) {
+ /* fast writeout of large file so
+ * calculate delay as if write
+ * happened only at max limit
+ */
+ next = ((total_written * llcache->time_quantum) / write_limit) - total_elapsed;
+ } else {
+ next = llcache->time_quantum - total_elapsed;
+ }
+ break;
}
+
}
free(lst);
+ /* Completed list without running out of allowed bytes or time */
if (idx == lst_count) {
- LOG(("Completed writeout list"));
- next = llcache->time_quantum - total_elapsed;
+ /* only reschedule if writing is making any progress at all */
+ if (total_written > 0) {
+ next = llcache->time_quantum - total_elapsed;
+ } else {
+ next = -1;
+ }
}
LOG(("writeout size:%d time:%d bandwidth:%dbytes/s",