Browse Source

Make a new proxy inherit the existing subproxies of the old one

master
Con Kolivas 10 years ago
parent
commit
f78f72dc4f
  1. 12
      src/stratifier.c

12
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) static void new_proxy(sdata_t *sdata, const int id)
{ {
bool exists = false, current = false; bool exists = false, current = false;
proxy_t *proxy; proxy_t *proxy, *proxy_list = NULL;
mutex_lock(&sdata->proxy_lock); mutex_lock(&sdata->proxy_lock);
HASH_FIND_INT(sdata->proxies, &id, proxy); 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); DL_APPEND(sdata->retired_proxies, proxy);
if (proxy == sdata->proxy) if (proxy == sdata->proxy)
current = true; current = true;
proxy_list = proxy->subproxies;
HASH_DELETE(sh, proxy_list, proxy);
proxy->subproxies = NULL;
} }
proxy = __generate_proxy(sdata, id); proxy = __generate_proxy(sdata, id);
if (current) if (current)
sdata->proxy = proxy; 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); mutex_unlock(&sdata->proxy_lock);
if (exists) if (exists)

Loading…
Cancel
Save