From f78f72dc4f87113c78c78209a4506bc454a36abe Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 23 Feb 2015 18:25:30 +1100 Subject: [PATCH] Make a new proxy inherit the existing subproxies of the old one --- src/stratifier.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/stratifier.c b/src/stratifier.c index 3bfaba2e..8cd7223f 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1191,7 +1191,7 @@ static proxy_t *current_proxy(sdata_t *sdata) static void new_proxy(sdata_t *sdata, const int id) { bool exists = false, current = false; - proxy_t *proxy; + proxy_t *proxy, *proxy_list = NULL; mutex_lock(&sdata->proxy_lock); HASH_FIND_INT(sdata->proxies, &id, proxy); @@ -1201,10 +1201,20 @@ static void new_proxy(sdata_t *sdata, const int id) DL_APPEND(sdata->retired_proxies, proxy); if (proxy == sdata->proxy) current = true; + proxy_list = proxy->subproxies; + HASH_DELETE(sh, proxy_list, proxy); + proxy->subproxies = NULL; } proxy = __generate_proxy(sdata, id); if (current) sdata->proxy = proxy; + /* The old proxy had subproxies on its list so steal its list and add + * ourselves to it. */ + if (proxy_list) { + HASH_DELETE(sh, proxy->subproxies, proxy); + proxy->subproxies = proxy_list; + HASH_ADD(sh, proxy->subproxies, subid, sizeof(int), proxy); + } mutex_unlock(&sdata->proxy_lock); if (exists)