mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-13 14:29:20 +03:00
fetchers: Apply cleaner ring handling mechanic to other fetchers
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
parent
083ba385d7
commit
5cfe0dfffc
@ -246,6 +246,7 @@ static void fetch_data_poll(lwc_string *scheme)
|
||||
{
|
||||
fetch_msg msg;
|
||||
struct fetch_data_context *c, *next;
|
||||
bool was_last_item = false;
|
||||
|
||||
if (ring == NULL) return;
|
||||
|
||||
@ -314,14 +315,28 @@ static void fetch_data_poll(lwc_string *scheme)
|
||||
* processing this item may have added to the ring.
|
||||
*/
|
||||
next = c->r_next;
|
||||
was_last_item = next == c;
|
||||
|
||||
fetch_remove_from_queues(c->parent_fetch);
|
||||
fetch_free(c->parent_fetch);
|
||||
|
||||
/* Having called into the fetch machinery, our ring might
|
||||
* have been updated
|
||||
*/
|
||||
if (was_last_item) {
|
||||
/* We were previously the last item in the ring
|
||||
* so let's reset to the head of the ring
|
||||
* and try again
|
||||
*/
|
||||
c = ring;
|
||||
} else {
|
||||
c = next;
|
||||
}
|
||||
|
||||
/* Advance to next ring entry, exiting if we've reached
|
||||
* the start of the ring or the ring has become empty
|
||||
*/
|
||||
} while ( (c = next) != ring && ring != NULL);
|
||||
} while (ring != NULL);
|
||||
}
|
||||
|
||||
nserror fetch_data_register(void)
|
||||
|
@ -792,6 +792,7 @@ static void fetch_file_process(struct fetch_file_context *ctx)
|
||||
static void fetch_file_poll(lwc_string *scheme)
|
||||
{
|
||||
struct fetch_file_context *c, *next;
|
||||
bool was_last_item = false;
|
||||
|
||||
if (ring == NULL) return;
|
||||
|
||||
@ -819,14 +820,28 @@ static void fetch_file_poll(lwc_string *scheme)
|
||||
* processing this item may have added to the ring.
|
||||
*/
|
||||
next = c->r_next;
|
||||
was_last_item = next == c;
|
||||
|
||||
fetch_remove_from_queues(c->fetchh);
|
||||
fetch_free(c->fetchh);
|
||||
|
||||
/* Having called into the fetch machinery, our ring might
|
||||
* have been updated
|
||||
*/
|
||||
if (was_last_item) {
|
||||
/* We were previously the last item in the ring
|
||||
* so let's reset to the head of the ring
|
||||
* and try again
|
||||
*/
|
||||
c = ring;
|
||||
} else {
|
||||
c = next;
|
||||
}
|
||||
|
||||
/* Advance to next ring entry, exiting if we've reached
|
||||
* the start of the ring or the ring has become empty
|
||||
*/
|
||||
} while ( (c = next) != ring && ring != NULL);
|
||||
} while (ring != NULL);
|
||||
}
|
||||
|
||||
nserror fetch_file_register(void)
|
||||
|
@ -434,6 +434,7 @@ static void fetch_resource_abort(void *ctx)
|
||||
static void fetch_resource_poll(lwc_string *scheme)
|
||||
{
|
||||
struct fetch_resource_context *c, *next;
|
||||
bool was_last_item = false;
|
||||
|
||||
if (ring == NULL) return;
|
||||
|
||||
@ -461,14 +462,28 @@ static void fetch_resource_poll(lwc_string *scheme)
|
||||
* as processing this item may have added to the ring
|
||||
*/
|
||||
next = c->r_next;
|
||||
was_last_item = next == c;
|
||||
|
||||
fetch_remove_from_queues(c->fetchh);
|
||||
fetch_free(c->fetchh);
|
||||
|
||||
/* Having called into the fetch machinery, our ring might
|
||||
* have been updated
|
||||
*/
|
||||
if (was_last_item) {
|
||||
/* We were previously the last item in the ring
|
||||
* so let's reset to the head of the ring
|
||||
* and try again
|
||||
*/
|
||||
c = ring;
|
||||
} else {
|
||||
c = next;
|
||||
}
|
||||
|
||||
/* Advance to next ring entry, exiting if we've reached
|
||||
* the start of the ring or the ring has become empty
|
||||
*/
|
||||
} while ( (c = next) != ring && ring != NULL);
|
||||
} while (ring != NULL);
|
||||
}
|
||||
|
||||
nserror fetch_resource_register(void)
|
||||
|
Loading…
Reference in New Issue
Block a user