From 4a8ea0d23bcff15ce3ccda9b3b85cb7b93345bf0 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 6 Dec 2009 13:30:08 +0100 Subject: upstream: Add upstream list parameter to upstream_get() to abstract it from the concrete list in the config struct. Now upstream.c does not use any reference to config any more. Michael --- src/reqs.c | 2 +- src/upstream.c | 5 +---- src/upstream.h | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/reqs.c b/src/reqs.c index 2ff7ac6..0d5f0e1 100644 --- a/src/reqs.c +++ b/src/reqs.c @@ -58,7 +58,7 @@ */ #ifdef UPSTREAM_SUPPORT # define UPSTREAM_CONFIGURED() (config.upstream_list != NULL) -# define UPSTREAM_HOST(host) upstream_get(host) +# define UPSTREAM_HOST(host) upstream_get(host, config.upstream_list) #else # define UPSTREAM_CONFIGURED() (0) # define UPSTREAM_HOST(host) (NULL) diff --git a/src/upstream.c b/src/upstream.c index cfab56f..dd91817 100644 --- a/src/upstream.c +++ b/src/upstream.c @@ -26,7 +26,6 @@ #include "upstream.h" #include "heap.h" -#include "main.h" #include "log.h" #ifdef UPSTREAM_SUPPORT @@ -165,10 +164,8 @@ upstream_cleanup: /* * Check if a host is in the upstream list */ -struct upstream *upstream_get (char *host) +struct upstream *upstream_get (char *host, struct upstream *up) { - struct upstream *up = config.upstream_list; - in_addr_t my_ip = INADDR_NONE; while (up) { diff --git a/src/upstream.h b/src/upstream.h index 1d4edc8..5125410 100644 --- a/src/upstream.h +++ b/src/upstream.h @@ -42,7 +42,7 @@ struct upstream { #ifdef UPSTREAM_SUPPORT extern void upstream_add (const char *host, int port, const char *domain, struct upstream **upstream_list); -struct upstream *upstream_get (char *host); +extern struct upstream *upstream_get (char *host, struct upstream *up); #endif /* UPSTREAM_SUPPORT */ #endif /* _TINYPROXY_UPSTREAM_H_ */ -- cgit v1.2.3