From 43d1336321eb57b95372ab21c41d33ed3569c995 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 1 Feb 2015 11:39:32 +1100 Subject: [PATCH] Increment proxy count only after new proxy is set up --- src/generator.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/generator.c b/src/generator.c index 97d49a08..b58988b5 100644 --- a/src/generator.c +++ b/src/generator.c @@ -853,8 +853,8 @@ static bool parse_reconnect(proxy_instance_t *proxi, json_t *val) ret = true; newsi = ckzalloc(sizeof(server_instance_t)); - newsi->id = ckp->proxies++; - ckp->servers = realloc(ckp->servers, sizeof(server_instance_t *) * ckp->proxies); + newsi->id = ckp->proxies; + ckp->servers = realloc(ckp->servers, sizeof(server_instance_t *) * (ckp->proxies + 1)); ckp->servers[newsi->id] = newsi; newsi->url = url; newsi->auth = strdup(si->auth); @@ -872,6 +872,7 @@ static bool parse_reconnect(proxy_instance_t *proxi, json_t *val) proxi->cs = &newsi->cs; /* Set chosen server only once all new proxy data exists */ + ckp->proxies++; ckp->chosen_server = newsi->id; out: return ret;