From 42573b3d134996973b3cbcfa4688b58e87fc478d Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Sun, 29 Oct 2017 12:31:18 +0100 Subject: Debugging : Squash / undo this commit later. --- content/fetchers/httplib_kolibri.c | 67 +++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 8 deletions(-) (limited to 'content/fetchers') diff --git a/content/fetchers/httplib_kolibri.c b/content/fetchers/httplib_kolibri.c index 28c3ec88d..9036ee28e 100644 --- a/content/fetchers/httplib_kolibri.c +++ b/content/fetchers/httplib_kolibri.c @@ -13,6 +13,8 @@ #include "content/fetchers/httplib_kolibri.h" #include "frontends/kolibrios/kolibri_http.h" +#include + struct httpfetcher { struct http_msg *handle; struct fetch *owner; @@ -27,37 +29,68 @@ struct httpfetcher *head = NULL; void add_to_poll(struct httpfetcher *newfetcher) { - NSLOG(fetch, DEBUG, "(head:0x%x) newfetcher 0x%x, newfetcher->handle 0x%x", head, newfetcher, newfetcher->handle); + NSLOG(fetch, ERROR, "(head:0x%x) newfetcher 0x%x, newfetcher->handle 0x%x", head, newfetcher, newfetcher->handle); struct httpfetcher *t = head; - assert(newfetcher->next == NULL); + while(t) { + NSLOG(fetch, ERROR, "ll node = 0x%x", t); + t=t->next; + } if(head == NULL) { head = newfetcher; assert(head->next == NULL); + NSLOG(fetch, ERROR, "(head:0x%x) ADDED newfetcher 0x%x, newfetcher->handle 0x%x", head, head, head->handle); } else { + t = head; + while(t->next != NULL) { + NSLOG(fetch, ERROR, "-- Looping t 0x%x, t->handle 0x%x", t->next, t->next->handle); t = t->next; } t->next = newfetcher; + NSLOG(fetch, ERROR, "(head:0x%x) ADDED newfetcher 0x%x, newfetcher->handle 0x%x, nn 0x%x", head, t->next, t->next->handle, t->next->next); + } + + struct httpfetcher *xx = head; + while(xx) { + NSLOG(fetch, ERROR, "ll node = 0x%x", xx); + xx=xx->next; } } struct httpfetcher* remove_from_poll(struct httpfetcher *removee) { struct httpfetcher *t = head, *p = head; - NSLOG(fetch, DEBUG, "(head=0x%x), remove: 0x%x , removee->handle: 0x%x", head, removee, removee->handle); + NSLOG(fetch, ERROR, "(head=0x%x), remove: 0x%x , removee->handle: 0x%x", head, removee, removee->handle); + while(t) { + NSLOG(fetch, ERROR, "BEFORE REMOVE ll node = 0x%x", t); + t=t->next; + } + + t = head; while(t) { if (t == removee) { if(t == head) { p = t->next; head = p; + + struct httpfetcher *xx = head; + while(xx) { + NSLOG(fetch, ERROR, "ll node = 0x%x", xx); + xx=xx->next; + } return head; break; } else { p->next = t->next; + struct httpfetcher *xx = head; + while(xx) { + NSLOG(fetch, ERROR, "ll node = 0x%x", xx); + xx=xx->next; + } return t->next; break; } @@ -261,22 +294,31 @@ void *setup_fetch(struct fetch *parent_fetch, struct nsurl *url, } bool start_fetch(void *httpf) { - NSLOG(fetch, DEBUG, "start_fetch : httpf: 0x%x", httpf); + assert(((struct httpfetcher *)httpf)->owner != NULL); + + NSLOG(fetch, ERROR, "httpf: 0x%x", httpf); add_to_poll((struct httpfetcher *) httpf); + + struct httpfetcher *wrapper = httpf; + + assert(((struct httpfetcher *)httpf)->owner != NULL); + + NSLOG(fetch, ERROR, "END OF add_to_poll: httpf: 0x%x, httpf->handle 0x%x, httpf->next 0x%x", wrapper, wrapper->handle, *wrapper ); return true; } bool abort_fetch(void *httpf) { - NSLOG(fetch, DEBUG, "aborting fetch 0x%x,", ((struct httpfetcher *)httpf)->owner); - remove_from_poll((struct httpfetcher *) httpf); + NSLOG(fetch, ERROR, "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 fetch 0x%x", ((struct httpfetcher *)httpf)->owner); + NSLOG(fetch, ERROR, "free_fetch fetch 0x%x", ((struct httpfetcher *)httpf)->owner); http_disconnect_asm((((struct httpfetcher *)httpf)->handle)); http_free_asm((((struct httpfetcher *)httpf)->handle)); @@ -302,6 +344,13 @@ void poll_fetch(lwc_string *scheme) { NSLOG(fetch, DEBUG, "--- Content Length (received / total): %d / %d", t->handle->content_received, t->handle->content_length); NSLOG(fetch, DEBUG, "--- ^ was for url : %s", nsurl_access(t->url)); + struct httpfetcher *xx = head; + while(xx) { + NSLOG(fetch, ERROR, "ll node poller = 0x%x", xx); + xx=xx->next; + } + NSLOG(fetch, ERROR, "ll node poller breakage --"); + int ret = http_receive_asm(t->handle); if(t->handle->flags & HTTP_ERRORS) { @@ -357,8 +406,9 @@ void poll_fetch(lwc_string *scheme) { if(t->handle->status == 304) { fetch_msg msg; msg.type = FETCH_NOTMODIFIED; + struct httpfetcher *t2 = remove_from_poll(t); fetch_send_callback(&msg, t->owner); - t = remove_from_poll(t); + t = t2; continue; } else { @@ -378,6 +428,7 @@ void poll_fetch(lwc_string *scheme) { fetch_send_callback(&msg, t->owner); t->headercbdone = true; t = t2; + NSLOG(fetch, INFO, "---- DID [3xx] : Redirect to %s", msg.data.redirect); /* t = t->next; */ /* t = head; */ continue; -- cgit v1.2.3