From: Willy Tarreau Date: Fri, 3 Feb 2023 13:53:34 +0000 (+0100) Subject: CLEANUP: listener/config: remove the special case for shards==1 X-Git-Tag: v2.8-dev3~4 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=484093df805400222ac795eba21128df2e1a0228;p=haproxy-3.0.git CLEANUP: listener/config: remove the special case for shards==1 In fact this case is already handled by the regular shards code, there is no need to special-case it. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index 75d0b56..fc8c7f2 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -2968,52 +2968,47 @@ init_proxies_list_stage1: /* apply thread masks and groups to all receivers */ list_for_each_entry(li, &bind_conf->listeners, by_bind) { - if (bind_conf->settings.shards <= 1) { - li->rx.bind_thread = thread_set_first_tmask(&bind_conf->thread_set); - li->rx.bind_tgroup = thread_set_first_group(&bind_conf->thread_set); - } else { - struct listener *new_li; - int shard, shards, todo, done, bit; - ulong mask; - - shards = bind_conf->settings.shards; - todo = my_popcountl(thread_set_first_tmask(&bind_conf->thread_set)); - - /* no more shards than total threads */ - if (shards > todo) - shards = todo; - - shard = done = bit = 0; - new_li = li; - - while (1) { - mask = 0; - while (done < todo) { - /* enlarge mask to cover next bit of bind_thread */ - while (!(thread_set_first_tmask(&bind_conf->thread_set) & (1UL << bit))) - bit++; - mask |= (1UL << bit); + struct listener *new_li; + int shard, shards, todo, done, bit; + ulong mask; + + shards = bind_conf->settings.shards; + todo = my_popcountl(thread_set_first_tmask(&bind_conf->thread_set)); + + /* no more shards than total threads */ + if (shards > todo) + shards = todo; + + shard = done = bit = 0; + new_li = li; + + while (1) { + mask = 0; + while (done < todo) { + /* enlarge mask to cover next bit of bind_thread */ + while (!(thread_set_first_tmask(&bind_conf->thread_set) & (1UL << bit))) bit++; - done += shards; - } + mask |= (1UL << bit); + bit++; + done += shards; + } - new_li->rx.bind_thread = thread_set_first_tmask(&bind_conf->thread_set) & mask; - new_li->rx.bind_tgroup = thread_set_first_group(&bind_conf->thread_set); - done -= todo; - - shard++; - if (shard >= shards) - break; - - /* create another listener for new shards */ - new_li = clone_listener(li); - if (!new_li) { - ha_alert("Out of memory while trying to allocate extra listener for shard %d in %s %s\n", - shard, proxy_type_str(curproxy), curproxy->id); - cfgerr++; - err_code |= ERR_FATAL | ERR_ALERT; - goto out; - } + new_li->rx.bind_thread = thread_set_first_tmask(&bind_conf->thread_set) & mask; + new_li->rx.bind_tgroup = thread_set_first_group(&bind_conf->thread_set); + done -= todo; + + shard++; + if (shard >= shards) + break; + + /* create another listener for new shards */ + new_li = clone_listener(li); + if (!new_li) { + ha_alert("Out of memory while trying to allocate extra listener for shard %d in %s %s\n", + shard, proxy_type_str(curproxy), curproxy->id); + cfgerr++; + err_code |= ERR_FATAL | ERR_ALERT; + goto out; } } }