ulong abs[(MAX_THREADS + LONGBITS - 1) / LONGBITS];
ulong rel[MAX_TGROUPS];
};
- uint nbgrp; /* number of non-empty groups in this set, 0 for abs */
+ ulong grps; /* bit field of all non-empty groups, 0 for abs */
};
/* tasklet classes */
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;
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++;
ulong mask, imask;
uint g;
- if (!ts->nbgrp) {
+ if (!ts->grps) {
/* unspecified group, IDs are global */
if (thread_set_is_empty(ts)) {
/* all threads of all groups, unless defgrp is set and
*/
for (g = defgrp ? defgrp-1 : 0; g < (defgrp ? defgrp : global.nbtgroups); g++) {
new_ts.rel[g] = ha_tgroup_info[g].threads_enabled;
- new_ts.nbgrp++;
+ if (new_ts.rel[g])
+ new_ts.grps |= 1UL << g;
}
} else {
/* some absolute threads are set, we must remap them to
/* now the mask exactly matches the threads to be enabled
* in this group.
*/
- if (!new_ts.rel[g] && mask)
- new_ts.nbgrp++;
new_ts.rel[g] |= mask;
+ if (new_ts.rel[g])
+ new_ts.grps |= 1UL << g;
}
}
} else {
}
new_ts.rel[g] = imask & mask;
- new_ts.nbgrp++;
+ if (new_ts.rel[g])
+ new_ts.grps |= 1UL << g;
}
}
if (ts) {
if (is_rel) {
/* group-relative thread numbers */
- if (!ts->rel[tg - 1])
- ts->nbgrp++;
+ ts->grps |= 1UL << (tg - 1);
if (max >= min) {
for (v = min; v <= max; v++)