From 6720beb2c100ae11855755e6e4d0310b2c6749ac Mon Sep 17 00:00:00 2001 From: James Bursa Date: Wed, 23 Jun 2004 15:41:50 +0000 Subject: [project @ 2004-06-23 15:41:50 by bursa] Fix fetchcache_go() treatment of contents which the initiator loses interest in (eg. wrong content-type). svn path=/import/netsurf/; revision=997 --- content/content.c | 33 +++++++++++++++++++++++++-------- content/content.h | 4 ++++ content/fetchcache.c | 9 ++++++--- 3 files changed, 35 insertions(+), 11 deletions(-) (limited to 'content') diff --git a/content/content.c b/content/content.c index 39b1c7389..dacb46df8 100644 --- a/content/content.c +++ b/content/content.c @@ -626,6 +626,29 @@ void content_add_user(struct content *c, } +/** + * Search the users of a content for the specified user. + * + * \return a content_user struct for the user, or 0 if not found + */ + +struct content_user * content_find_user(struct content *c, + void (*callback)(content_msg msg, struct content *c, void *p1, + void *p2, union content_msg_data data), + void *p1, void *p2) +{ + struct content_user *user; + + /* user_list starts with a sentinel */ + for (user = c->user_list; user->next && + !(user->next->callback == callback && + user->next->p1 == p1 && + user->next->p2 == p2); user = user->next) + ; + return user->next; +} + + /** * Remove a callback user. * @@ -690,18 +713,12 @@ void content_stop(struct content *c, assert(c->status == CONTENT_STATUS_READY); - /* user_list starts with a sentinel */ - for (user = c->user_list; user->next != 0 && - !(user->next->callback == callback && - user->next->p1 == p1 && - user->next->p2 == p2); user = user->next) - ; - if (user->next == 0) { + user = content_find_user(c, callback, p1, p2); + if (!user) { LOG(("user not found in list")); assert(0); return; } - user = user->next; LOG(("%p %s: stop user %p %p %p", c, c->url, callback, p1, p2)); user->stop = true; diff --git a/content/content.h b/content/content.h index 1048df818..09d59be45 100644 --- a/content/content.h +++ b/content/content.h @@ -270,6 +270,10 @@ void content_add_user(struct content *c, void (*callback)(content_msg msg, struct content *c, void *p1, void *p2, union content_msg_data data), void *p1, void *p2); +struct content_user * content_find_user(struct content *c, + void (*callback)(content_msg msg, struct content *c, void *p1, + void *p2, union content_msg_data data), + void *p1, void *p2); void content_remove_user(struct content *c, void (*callback)(content_msg msg, struct content *c, void *p1, void *p2, union content_msg_data data), diff --git a/content/fetchcache.c b/content/fetchcache.c index fb671ea50..8d3272c94 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -172,12 +172,15 @@ void fetchcache_go(struct content *content, char *referer, } else if (content->status == CONTENT_STATUS_READY) { callback(CONTENT_MSG_LOADING, content, p1, p2, msg_data); - callback(CONTENT_MSG_READY, content, p1, p2, msg_data); + if (content_find_user(content, callback, p1, p2)) + callback(CONTENT_MSG_READY, content, p1, p2, msg_data); } else if (content->status == CONTENT_STATUS_DONE) { callback(CONTENT_MSG_LOADING, content, p1, p2, msg_data); - callback(CONTENT_MSG_READY, content, p1, p2, msg_data); - callback(CONTENT_MSG_DONE, content, p1, p2, msg_data); + if (content_find_user(content, callback, p1, p2)) + callback(CONTENT_MSG_READY, content, p1, p2, msg_data); + if (content_find_user(content, callback, p1, p2)) + callback(CONTENT_MSG_DONE, content, p1, p2, msg_data); } else if (content->status == CONTENT_STATUS_ERROR) { /* shouldn't usually occur */ -- cgit v1.2.3