summaryrefslogtreecommitdiff
path: root/content/fetchers/httplib_kolibri.c
diff options
context:
space:
mode:
authorAshish Gupta <ashmew2@gmail.com>2017-10-26 01:45:36 +0200
committerAshish Gupta <ashmew2@gmail.com>2017-10-26 01:45:36 +0200
commitf22a0ef3cd7aa7071c2ed85630a85eb1b2dd2e36 (patch)
treeb4d42a04a80a3e8e6dc60fbdbb89ca6c68a18722 /content/fetchers/httplib_kolibri.c
parent346baf80d8a0785d48a2faeae0af42258e22150d (diff)
downloadnetsurf-f22a0ef3cd7aa7071c2ed85630a85eb1b2dd2e36.tar.gz
netsurf-f22a0ef3cd7aa7071c2ed85630a85eb1b2dd2e36.tar.bz2
Fix infinite fetching processing in http fetcher
Diffstat (limited to 'content/fetchers/httplib_kolibri.c')
-rw-r--r--content/fetchers/httplib_kolibri.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/content/fetchers/httplib_kolibri.c b/content/fetchers/httplib_kolibri.c
index 93dfce2be..28c3ec88d 100644
--- a/content/fetchers/httplib_kolibri.c
+++ b/content/fetchers/httplib_kolibri.c
@@ -27,7 +27,7 @@ struct httpfetcher *head = NULL;
void add_to_poll(struct httpfetcher *newfetcher) {
- NSLOG(fetch, DEBUG, "-=- add: newfetcher 0x%x, newfetcher->handle 0x%x", newfetcher, newfetcher->handle);
+ NSLOG(fetch, DEBUG, "(head:0x%x) newfetcher 0x%x, newfetcher->handle 0x%x", head, newfetcher, newfetcher->handle);
struct httpfetcher *t = head;
assert(newfetcher->next == NULL);
@@ -44,12 +44,12 @@ void add_to_poll(struct httpfetcher *newfetcher) {
}
}
-struct httpfetcher* remove_from_poll(struct http_msg *donehttp) {
+struct httpfetcher* remove_from_poll(struct httpfetcher *removee) {
struct httpfetcher *t = head, *p = head;
- NSLOG(fetch, DEBUG, "-=- remove: (->handle) donehttp 0x%x", donehttp);
+ NSLOG(fetch, DEBUG, "(head=0x%x), remove: 0x%x , removee->handle: 0x%x", head, removee, removee->handle);
while(t) {
- if (t->handle == donehttp) {
+ if (t == removee) {
if(t == head) {
p = t->next;
head = p;
@@ -65,7 +65,7 @@ struct httpfetcher* remove_from_poll(struct http_msg *donehttp) {
p = t;
t = t->next;
- }
+ }
return head;
}
@@ -261,25 +261,24 @@ void *setup_fetch(struct fetch *parent_fetch, struct nsurl *url,
}
bool start_fetch(void *httpf) {
- NSLOG(fetch, DEBUG, "-=- start_fetch : httpf: 0x%x", httpf);
+ NSLOG(fetch, DEBUG, "start_fetch : httpf: 0x%x", httpf);
add_to_poll((struct httpfetcher *) httpf);
return true;
}
bool abort_fetch(void *httpf) {
- NSLOG(fetch, DEBUG, "aborting fetch 0x%x", ((struct httpfetcher *)httpf)->owner);
- remove_from_poll(((struct httpfetcher *) httpf)->handle);
+ NSLOG(fetch, DEBUG, "aborting fetch 0x%x,", ((struct httpfetcher *)httpf)->owner);
+ remove_from_poll((struct httpfetcher *) httpf);
fetch_remove_from_queues(((struct httpfetcher *)httpf)->owner);
fetch_free(((struct httpfetcher *)httpf)->owner);
return true;
}
bool free_fetch(void *httpf) {
- NSLOG(fetch, DEBUG, "free_fetch called for 0x%x", ((struct httpfetcher *)httpf)->owner);
+ NSLOG(fetch, DEBUG, "free_fetch fetch 0x%x", ((struct httpfetcher *)httpf)->owner);
http_disconnect_asm((((struct httpfetcher *)httpf)->handle));
- NSLOG(fetch, DEBUG, "Freeing fetch 0x%x", ((struct httpfetcher *)httpf)->owner);
http_free_asm((((struct httpfetcher *)httpf)->handle));
free((struct httpfetcher *)httpf);
@@ -292,6 +291,7 @@ void poll_fetch(lwc_string *scheme) {
assert(supported_scheme);
struct httpfetcher *t = head;
+ NSLOG(fetch, DEBUG, "poller head = 0x%x", t);
while(t != NULL) {
NSLOG(fetch, DEBUG, "-- Polling for t 0x%x, http_msg 0x%x, fetch 0x%x [ hcbdone = %s ]", t, t->handle, t->owner, t->headercbdone == true ? "true" : "false");
@@ -310,8 +310,12 @@ void poll_fetch(lwc_string *scheme) {
NSLOG(fetch, ERROR, "---- http_msg -> flags = 0x%x", t->handle->flags);
msg.data.header_or_data.buf = (const uint8_t *) "HTTPLIB ERROR";
msg.data.header_or_data.len = strlen("HTTPLIB ERROR");
+ struct httpfetcher *t2 = remove_from_poll(t);
fetch_send_callback(&msg, t->owner);
t->headercbdone = true;
+
+ t = t2;
+ continue;
}
if(t->headercbdone == false) {
@@ -354,9 +358,7 @@ void poll_fetch(lwc_string *scheme) {
fetch_msg msg;
msg.type = FETCH_NOTMODIFIED;
fetch_send_callback(&msg, t->owner);
- t = remove_from_poll(t->handle);
- /* t = t->next; */
- /* t = head; */
+ t = remove_from_poll(t);
continue;
}
else {
@@ -372,9 +374,10 @@ void poll_fetch(lwc_string *scheme) {
msg.data.redirect = newlocation;
NSLOG(fetch, INFO, "---- [3xx] : Redirect to %s", msg.data.redirect);
+ struct httpfetcher *t2 = remove_from_poll(t);
fetch_send_callback(&msg, t->owner);
t->headercbdone = true;
- t = remove_from_poll(t->handle);
+ t = t2;
/* t = t->next; */
/* t = head; */
continue;
@@ -387,8 +390,9 @@ void poll_fetch(lwc_string *scheme) {
fetch_send_callback(&msg, t->owner);
t->headercbdone = true;
fetch_remove_from_queues(t->owner);
+ struct httpfetcher *t2 = remove_from_poll(t);
fetch_free(t->owner);
- t = remove_from_poll(t->handle);
+ t = t2;
/* t = t->next; */
/* t = head; */
continue;
@@ -431,11 +435,11 @@ void poll_fetch(lwc_string *scheme) {
fetch_send_callback(&msg, t->owner);
NSLOG(fetch, DEBUG, "---- FETCH_FINISHED for fetch 0x%x", t->owner);
- struct httpfetcher *tnext = t->next;
fetch_remove_from_queues(t->owner);
- fetch_free(t->owner);
/* t = head; */
- t = remove_from_poll(t->handle);
+ struct httpfetcher *t2 = remove_from_poll(t);
+ fetch_free(t->owner);
+ t = t2;
/* t = next; */
continue;
}