summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/fetchers/about.c9
-rw-r--r--content/fetchers/data.c27
-rw-r--r--content/fetchers/file.c9
-rw-r--r--content/fetchers/resource.c9
4 files changed, 32 insertions, 22 deletions
diff --git a/content/fetchers/about.c b/content/fetchers/about.c
index c4a376a29..9def04a2c 100644
--- a/content/fetchers/about.c
+++ b/content/fetchers/about.c
@@ -353,10 +353,6 @@ static void fetch_about_poll(const char *scheme)
/* Iterate over ring, processing each pending fetch */
c = ring;
do {
- /* Take a copy of the next pointer as we may destroy
- * the ring item we're currently processing */
- next = c->r_next;
-
/* Ignore fetches that have been flagged as locked.
* This allows safe re-entrant calls to this function.
* Re-entrancy can occur if, as a result of a callback,
@@ -364,6 +360,7 @@ static void fetch_about_poll(const char *scheme)
* again.
*/
if (c->locked == true) {
+ next = c->r_next;
continue;
}
@@ -373,6 +370,10 @@ static void fetch_about_poll(const char *scheme)
c->handler(c);
}
+ /* Compute next fetch item at the last possible moment
+ * as processing this item may have added to the ring
+ */
+ next = c->r_next;
fetch_remove_from_queues(c->fetchh);
fetch_free(c->fetchh);
diff --git a/content/fetchers/data.c b/content/fetchers/data.c
index 2396a797b..5abe2d6dd 100644
--- a/content/fetchers/data.c
+++ b/content/fetchers/data.c
@@ -235,10 +235,6 @@ static void fetch_data_poll(const char *scheme)
/* Iterate over ring, processing each pending fetch */
c = ring;
do {
- /* Take a copy of the next pointer as we may destroy
- * the ring item we're currently processing */
- next = c->r_next;
-
/* Ignore fetches that have been flagged as locked.
* This allows safe re-entrant calls to this function.
* Re-entrancy can occur if, as a result of a callback,
@@ -246,11 +242,12 @@ static void fetch_data_poll(const char *scheme)
* again.
*/
if (c->locked == true) {
+ next = c->r_next;
continue;
}
/* Only process non-aborted fetches */
- if (!c->aborted && fetch_data_process(c) == true) {
+ if (c->aborted == false && fetch_data_process(c) == true) {
char header[64];
fetch_set_http_code(c->parent_fetch, 200);
@@ -265,17 +262,22 @@ static void fetch_data_poll(const char *scheme)
fetch_data_send_callback(FETCH_HEADER, c, header,
strlen(header), FETCH_ERROR_NO_ERROR);
- snprintf(header, sizeof header, "Content-Length: %zd",
+ if (c->aborted == false) {
+ snprintf(header, sizeof header,
+ "Content-Length: %zd",
c->datalen);
- fetch_data_send_callback(FETCH_HEADER, c, header,
- strlen(header), FETCH_ERROR_NO_ERROR);
+ fetch_data_send_callback(FETCH_HEADER, c,
+ header, strlen(header),
+ FETCH_ERROR_NO_ERROR);
+ }
- if (!c->aborted) {
+ if (c->aborted == false) {
fetch_data_send_callback(FETCH_DATA,
c, c->data, c->datalen,
FETCH_ERROR_NO_ERROR);
}
- if (!c->aborted) {
+
+ if (c->aborted == false) {
fetch_data_send_callback(FETCH_FINISHED,
c, 0, 0, FETCH_ERROR_NO_ERROR);
}
@@ -288,6 +290,11 @@ static void fetch_data_poll(const char *scheme)
assert(c->locked == false);
}
+ /* Compute next fetch item at the last possible moment as
+ * processing this item may have added to the ring.
+ */
+ next = c->r_next;
+
fetch_remove_from_queues(c->parent_fetch);
fetch_free(c->parent_fetch);
diff --git a/content/fetchers/file.c b/content/fetchers/file.c
index 2f69fe583..9cdc21054 100644
--- a/content/fetchers/file.c
+++ b/content/fetchers/file.c
@@ -599,10 +599,6 @@ static void fetch_file_poll(const char *scheme)
/* Iterate over ring, processing each pending fetch */
c = ring;
do {
- /* Take a copy of the next pointer as we may destroy
- * the ring item we're currently processing */
- next = c->r_next;
-
/* Ignore fetches that have been flagged as locked.
* This allows safe re-entrant calls to this function.
* Re-entrancy can occur if, as a result of a callback,
@@ -610,6 +606,7 @@ static void fetch_file_poll(const char *scheme)
* again.
*/
if (c->locked == true) {
+ next = c->r_next;
continue;
}
@@ -619,6 +616,10 @@ static void fetch_file_poll(const char *scheme)
fetch_file_process(c);
}
+ /* Compute next fetch item at the last possible moment as
+ * processing this item may have added to the ring.
+ */
+ next = c->r_next;
fetch_remove_from_queues(c->fetchh);
fetch_free(c->fetchh);
diff --git a/content/fetchers/resource.c b/content/fetchers/resource.c
index 2818305d0..c8fb060b6 100644
--- a/content/fetchers/resource.c
+++ b/content/fetchers/resource.c
@@ -234,10 +234,6 @@ static void fetch_resource_poll(const char *scheme)
/* Iterate over ring, processing each pending fetch */
c = ring;
do {
- /* Take a copy of the next pointer as we may destroy
- * the ring item we're currently processing */
- next = c->r_next;
-
/* Ignore fetches that have been flagged as locked.
* This allows safe re-entrant calls to this function.
* Re-entrancy can occur if, as a result of a callback,
@@ -245,6 +241,7 @@ static void fetch_resource_poll(const char *scheme)
* again.
*/
if (c->locked == true) {
+ next = c->r_next;
continue;
}
@@ -254,6 +251,10 @@ static void fetch_resource_poll(const char *scheme)
c->handler(c);
}
+ /* Compute next fetch item at the last possible moment
+ * as processing this item may have added to the ring
+ */
+ next = c->r_next;
fetch_remove_from_queues(c->fetchh);
fetch_free(c->fetchh);