Fix backend fetcher poll loops

svn path=/trunk/netsurf/; revision=11775
This commit is contained in:
John Mark Bell 2011-02-23 22:41:17 +00:00
parent 79d9d6abab
commit 308f549f78
4 changed files with 32 additions and 22 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);