From d66befef02797141291b619922830b96f56a038b Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 5 Feb 2015 13:56:21 +1100 Subject: [PATCH] Don't reset the chosen_server value in live_proxy --- src/generator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/generator.c b/src/generator.c index a18a5cc4..1368985e 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1475,16 +1475,16 @@ out: /* Cycle through the available proxies and find the first alive one */ static proxy_instance_t *live_proxy(ckpool_t *ckp) { + int i, start_from = ckp->chosen_server; proxy_instance_t *alive = NULL; connsock_t *cs; - int i; LOGDEBUG("Attempting to connect to proxy"); retry: if (!ping_main(ckp)) goto out; - for (i = ckp->chosen_server; i < ckp->proxies; i++) { + for (i = start_from; i < ckp->proxies; i++) { proxy_instance_t *proxi; server_instance_t *si; @@ -1499,13 +1499,13 @@ retry: if (!alive) { send_proc(ckp->connector, "reject"); send_proc(ckp->stratifier, "dropall"); - if (!ckp->chosen_server) { + if (!start_from) { LOGWARNING("Failed to connect to any servers as proxy, retrying in 5s!"); sleep(5); } goto retry; } - ckp->chosen_server = 0; + start_from = 0; cs = alive->cs; LOGNOTICE("Connected to upstream server %s:%s as proxy%s", cs->url, cs->port, ckp->passthrough ? " in passthrough mode" : "");