summaryrefslogtreecommitdiff
path: root/content/fetchers/httplib_kolibri.c
diff options
context:
space:
mode:
authorAshish Gupta <ashmew2@gmail.com>2017-10-18 00:23:09 +0200
committerAshish Gupta <ashmew2@gmail.com>2017-10-25 22:04:56 +0200
commit4980d387dc4fe25ab83b00e460c48482725636ba (patch)
tree54717a3ab6ae72d839bc8fc74ec5476adab5666a /content/fetchers/httplib_kolibri.c
parentff154031b0fd843c2973788e3110ab25b845c297 (diff)
downloadnetsurf-4980d387dc4fe25ab83b00e460c48482725636ba.tar.gz
netsurf-4980d387dc4fe25ab83b00e460c48482725636ba.tar.bz2
Fix polling of http connections when going through linked list.
Diffstat (limited to 'content/fetchers/httplib_kolibri.c')
-rw-r--r--content/fetchers/httplib_kolibri.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/content/fetchers/httplib_kolibri.c b/content/fetchers/httplib_kolibri.c
index 25e5a1060..18055d1ae 100644
--- a/content/fetchers/httplib_kolibri.c
+++ b/content/fetchers/httplib_kolibri.c
@@ -13,11 +13,10 @@
#include "content/fetchers/httplib_kolibri.h"
#include "frontends/kolibrios/kolibri_http.h"
-extern struct fetch;
-
struct httpfetcher {
struct http_msg *handle;
struct fetch *owner;
+ nsurl *url;
bool headercbdone;
unsigned int datalen_cb_done;
@@ -45,7 +44,7 @@ void add_to_poll(struct httpfetcher *newfetcher) {
}
}
-void remove_from_poll(struct http_msg *donehttp) {
+struct httpfetcher* remove_from_poll(struct http_msg *donehttp) {
struct httpfetcher *t = head, *p = head;
LOG("-=- remove: (->handle) donehttp 0x%x", donehttp);
@@ -54,10 +53,12 @@ void remove_from_poll(struct http_msg *donehttp) {
if(t == head) {
p = t->next;
head = p;
+ return head;
break;
}
else {
p->next = t->next;
+ return t->next;
break;
}
}
@@ -65,6 +66,8 @@ void remove_from_poll(struct http_msg *donehttp) {
p = t;
t = t->next;
}
+
+ return head;
}
bool init_fetcher(lwc_string *scheme) {
@@ -252,6 +255,7 @@ void *setup_fetch(struct fetch *parent_fetch, struct nsurl *url,
newfetcher->next = NULL;
newfetcher->handle = request;
+ newfetcher->url = url;
newfetcher->headercbdone = false;
newfetcher->owner = parent_fetch;
newfetcher->datalen_cb_done = 0;
@@ -299,6 +303,7 @@ void poll_fetch(lwc_string *scheme) {
LOG("--- Header Length: %d", t->handle->header_length);
LOG("--- Content starts at : %x", &(t->handle->content_ptr));
LOG("--- Content Length (received / total): %d / %d", t->handle->content_received, t->handle->content_length);
+ LOG("--- ^ was for url : %s", nsurl_access(t->url));
int ret = http_receive_asm(t->handle);
@@ -352,9 +357,9 @@ void poll_fetch(lwc_string *scheme) {
fetch_msg msg;
msg.type = FETCH_NOTMODIFIED;
fetch_send_callback(&msg, t->owner);
- remove_from_poll(t->handle);
+ t = remove_from_poll(t->handle);
/* t = t->next; */
- t = head;
+ /* t = head; */
continue;
}
else {
@@ -372,9 +377,9 @@ void poll_fetch(lwc_string *scheme) {
LOG("---- [3xx] : Redirect to %s", msg.data.redirect);
fetch_send_callback(&msg, t->owner);
t->headercbdone = true;
- remove_from_poll(t->handle);
+ t = remove_from_poll(t->handle);
/* t = t->next; */
- t = head;
+ /* t = head; */
continue;
}
}
@@ -384,11 +389,11 @@ void poll_fetch(lwc_string *scheme) {
LOG(" ---- [ERROR] Unhandled HTTP Code : %d", t->handle->status);
fetch_send_callback(&msg, t->owner);
t->headercbdone = true;
- remove_from_poll(t->handle);
fetch_remove_from_queues(t->owner);
fetch_free(t->owner);
+ t = remove_from_poll(t->handle);
/* t = t->next; */
- t = head;
+ /* t = head; */
continue;
}
}
@@ -430,19 +435,17 @@ void poll_fetch(lwc_string *scheme) {
LOG("---- FETCH_FINISHED for fetch 0x%x", t->owner);
struct httpfetcher *tnext = t->next;
- remove_from_poll(t->handle);
fetch_remove_from_queues(t->owner);
fetch_free(t->owner);
- t = head;
- /* t = tnext; */
+ /* t = head; */
+ t = remove_from_poll(t->handle);
+ /* t = next; */
continue;
}
LOG("Main loop: t going from 0x%x to 0x%x", t->owner, t->next != NULL ? t->next->owner : NULL);
t = t->next;
}
-
- LOG("=Returning from %s", __func__);
}
void finalize_fetcher(lwc_string *scheme) {