summaryrefslogtreecommitdiff
path: root/content/fetch.c
diff options
context:
space:
mode:
Diffstat (limited to 'content/fetch.c')
-rw-r--r--content/fetch.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/content/fetch.c b/content/fetch.c
index 3d1183aa0..2160204ef 100644
--- a/content/fetch.c
+++ b/content/fetch.c
@@ -61,17 +61,27 @@
/* Define this to turn on verbose fetch logging */
#undef DEBUG_FETCH_VERBOSE
-#define DEBUG_FETCH_VERBOSE
-
-/** The maximum number of fetchers that can be added */
-#define MAX_FETCHERS 8
+/** Verbose fetcher logging */
#ifdef DEBUG_FETCH_VERBOSE
#define FETCH_LOG(x) LOG(x)
#else
#define FETCH_LOG(x)
#endif
+/** The maximum number of fetchers that can be added */
+#define MAX_FETCHERS 8
+
+/** The time in ms between polling the fetchers.
+ *
+ * \todo The schedule timeout should be profiled to see if there is a
+ * better value or even if it needs to be dynamic.
+ */
+#define SCHEDULE_TIME 10
+
+/** The fdset timeout in ms */
+#define FDSET_TIMEOUT 1000
+
/**
* Information about a fetcher for a given scheme.
*/
@@ -265,7 +275,7 @@ static void fetcher_poll(void *unused)
}
/* schedule active fetchers to run again in 10ms */
- guit->browser->schedule(10, fetcher_poll, NULL);
+ guit->browser->schedule(SCHEDULE_TIME, fetcher_poll, NULL);
}
}
@@ -290,9 +300,28 @@ void fetcher_quit(void)
{
int fetcherd; /* fetcher index */
for (fetcherd = 0; fetcherd < MAX_FETCHERS; fetcherd++) {
- if (fetchers[fetcherd].refcount > 0) {
- /* assert if the fetcher is active at quit */
- assert(fetchers[fetcherd].refcount == 1);
+ if (fetchers[fetcherd].refcount > 1) {
+ /* fetcher still has reference at quit. This
+ * should not happen as the fetch should have
+ * been aborted in llcache shutdown.
+ *
+ * This appears to be normal behaviour if a
+ * curl operation is still in progress at exit
+ * as the abort waits for curl to complete.
+ *
+ * We could make the user wait for curl to
+ * complete but we are exiting anyway so thats
+ * unhelpful. Instead we just log it and force
+ * the reference count to allow the fetcher to
+ * be stopped.
+ */
+ LOG(("Fetcher for scheme %s still has %d active users at quit.",
+ lwc_string_data(fetchers[fetcherd].scheme),
+ fetchers[fetcherd].refcount));
+
+ fetchers[fetcherd].refcount = 1;
+ }
+ if (fetchers[fetcherd].refcount == 1) {
fetch_unref_fetcher(fetcherd);
}
@@ -376,7 +405,7 @@ nserror fetcher_fdset(fd_set *read_fd_set,
* select on. All the other fetchers continue to need
* polling frequently.
*/
- guit->browser->schedule(1000, fetcher_poll, NULL);
+ guit->browser->schedule(FDSET_TIMEOUT, fetcher_poll, NULL);
}
*maxfd_out = maxfd;