From 31b0e4df67f64da86385344823dd4caffaccd6e8 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 14 Feb 2015 15:59:37 +1100 Subject: [PATCH] Only check for existence of current proxy when switching, not best which may have already been set to the alive proxy --- src/generator.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/src/generator.c b/src/generator.c index 227214da..557b0c27 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1693,29 +1693,6 @@ static void *passthrough_recv(void *arg) return NULL; } -static proxy_instance_t *best_proxy(ckpool_t *ckp, gdata_t *gdata) -{ - proxy_instance_t *ret = NULL, *proxi, *tmp; - - mutex_lock(&gdata->lock); - HASH_ITER(hh, gdata->proxies, proxi, tmp) { - if (proxi->alive) { - if (!ret) { - ret = proxi; - continue; - } - if (proxi->id < ret->id) - ret = proxi; - } - } - gdata->proxy = ret; - mutex_unlock(&gdata->lock); - - send_proc(ckp->connector, ret ? "accept" : "reject"); - return ret; -} - -#if 0 static proxy_instance_t *current_proxy(gdata_t *gdata) { proxy_instance_t *ret; @@ -1726,7 +1703,6 @@ static proxy_instance_t *current_proxy(gdata_t *gdata) return ret; } -#endif /* For receiving messages from the upstream proxy, also responsible for setting * up the connection and testing it's alive. */ @@ -1773,8 +1749,7 @@ static void *proxy_recv(void *arg) } /* Wait 90 seconds before declaring this upstream pool alive * to prevent switching to unstable pools. */ - if (!alive && (!best_proxy(ckp, gdata) || - time(NULL) - proxi->reconnect_time > 90)) { + if (!alive && (!current_proxy(gdata) || time(NULL) - proxi->reconnect_time > 90)) { LOGWARNING("Proxy %d:%s recovered", proxi->id, proxi->si->url); proxi->reconnect_time = 0; send_proc(ckp->generator, "reconnect");