From b85b1f5ba5ae6a49811c1799296dc07d2ef8e7e7 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Mon, 20 Dec 2010 10:32:15 +0000 Subject: Make fetch.c use new RING_COUNTBYLWCHOST svn path=/trunk/netsurf/; revision=11108 --- content/fetch.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'content') diff --git a/content/fetch.c b/content/fetch.c index 4cd1ed31a..433a06fd9 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -34,6 +34,8 @@ #include #include +#include + #include "utils/config.h" #include "content/fetch.h" #include "content/fetchers/fetch_curl.h" @@ -78,6 +80,7 @@ struct fetch { bool verifiable; /**< Transaction is verifiable */ void *p; /**< Private data for callback. */ char *host; /**< Host part of URL. */ + lwc_string *lwc_host; /**< Host part of URL, interned */ long http_code; /**< HTTP response code, or 0. */ scheme_fetcher *ops; /**< Fetcher operations for this fetch, NULL if not set. */ @@ -271,7 +274,11 @@ struct fetch * fetch_start(const char *url, const char *referer, fetch->fetcher_handle = NULL; fetch->ops = NULL; fetch->fetch_is_active = false; - + fetch->lwc_host = NULL; + + if (lwc_intern_string(host, strlen(host), &fetch->lwc_host) != lwc_error_ok) + goto failed; + if (referer != NULL) { fetch->referer = strdup(referer); if (fetch->referer == NULL) @@ -338,6 +345,8 @@ failed: free(scheme); free(fetch->url); free(fetch->referer); + if (fetch->lwc_host != NULL) + lwc_string_unref(fetch->lwc_host); free(fetch); return NULL; @@ -415,8 +424,8 @@ bool fetch_choose_and_dispatch(void) * fetch ring */ int countbyhost; - RING_COUNTBYHOST(struct fetch, fetch_ring, countbyhost, - queueitem->host); + RING_COUNTBYLWCHOST(struct fetch, fetch_ring, countbyhost, + queueitem->lwc_host); if (countbyhost < option_max_fetchers_per_host) { /* We can dispatch this item in theory */ return fetch_dispatch_job(queueitem); @@ -477,7 +486,9 @@ void fetch_free(struct fetch *f) free(f->host); if (f->referer) free(f->referer); - free(f); + if (f->lwc_host != NULL) + lwc_string_unref(f->lwc_host); + free(f); } -- cgit v1.2.3