MINOR: thread: keep a bitmask of enabled groups in thread_set
We're only checking for 0, 1, or >1 groups enabled there, and we'll soon
need to be more precise and know quickly which groups are non-empty.
Let's just replace the count with a mask of enabled groups. This will
allow to quickly spot the presence of any such group in a set.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 52f40d6..4272c3d 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -2998,18 +2998,16 @@
bit = (bind_conf->thread_set.rel[grp] & ~mask) & -(bind_conf->thread_set.rel[grp] & ~mask);
new_ts.rel[grp] |= bit;
mask |= bit;
-
- if (!atleast2(new_ts.rel[grp])) // first time we add a bit: new group
- new_ts.nbgrp++;
+ new_ts.grps |= 1UL << grp;
done += shards;
};
- BUG_ON(!new_ts.nbgrp); // no more bits left unassigned
+ BUG_ON(!new_ts.grps); // no more bits left unassigned
- if (new_ts.nbgrp > 1) {
+ if (atleast2(new_ts.grps)) {
ha_alert("Proxy '%s': shard number %d spans %d groups in 'bind %s' at [%s:%d]\n",
- curproxy->id, shard, new_ts.nbgrp, bind_conf->arg, bind_conf->file, bind_conf->line);
+ curproxy->id, shard, my_popcountl(new_ts.grps), bind_conf->arg, bind_conf->file, bind_conf->line);
cfgerr++;
err_code |= ERR_FATAL | ERR_ALERT;
goto out;
@@ -4450,7 +4448,7 @@
free(err);
cfgerr++;
}
- else if (bind_conf->thread_set.nbgrp > 1) {
+ else if (atleast2(bind_conf->thread_set.grps)) {
ha_alert("Peers section '%s': 'thread' spans more than one group in 'bind %s' at [%s:%d].\n",
curpeers->peers_fe->id, bind_conf->arg, bind_conf->file, bind_conf->line);
cfgerr++;