From d1fe21601e47bfc9687f08202fb9ce44d4d2d24f Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 17 Feb 2015 15:45:57 +1100 Subject: [PATCH] Don't create subproxies except when appropriate --- src/stratifier.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 8aa36fb8..7e8b4aa6 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1283,9 +1283,9 @@ static void update_notify(ckpool_t *ckp, const char *cmd) } json_get_int(&id, val, "proxy"); json_get_int(&subid, val, "subproxy"); - proxy = subproxy_by_id(sdata, id, subid); - if (unlikely(!proxy->subscribed)) { - LOGNOTICE("No valid proxy %d:%d subscription to update notify yet", id, subid); + proxy = existing_subproxy(sdata, id, subid); + if (unlikely(!proxy || !proxy->subscribed)) { + LOGINFO("No valid proxy %d:%d subscription to update notify yet", id, subid); goto out; } if (!subid) @@ -1397,7 +1397,11 @@ static void update_diff(ckpool_t *ckp, const char *cmd) LOGNOTICE("Got updated diff for proxy %d", id); else LOGINFO("Got updated diff for proxy %d:%d", id, subid); - proxy = subproxy_by_id(sdata, id, subid); + proxy = existing_subproxy(sdata, id, subid); + if (!proxy) { + LOGINFO("No existing subproxy %d:%d to update diff", id, subid); + return; + } /* We only really care about integer diffs so clamp the lower limit to * 1 or it will round down to zero. */ @@ -2043,7 +2047,9 @@ static void dead_proxy(sdata_t *sdata, const char *buf) proxy_t *proxy; sscanf(buf, "deadproxy=%d:%d", &id, &subid); - proxy = subproxy_by_id(sdata, id, subid); + proxy = existing_subproxy(sdata, id, subid); + if (!proxy) + return; proxy->dead = true; LOGNOTICE("Stratifier dropping clients from proxy %d:%d", id, subid);