Since 3.0-dev7 with commit
1a088da7c2 ("MAJOR: stktable: split the keys
across multiple shards to reduce contention"), building without threads
yields a warning about the shard not being used. This is because the
locks API does nothing of its arguments, which is the only place where
the shard is being used. We cannot modify the lock API to pretend to
consume its argument because quite often it's not even instantiated.
Let's just pretend we consume shard using an explict ALREADY_CHECKED()
statement instead. While we're at it, let's make sure that XXH32() is
not called when there is a single bucket!
No backport is needed.
*/
static inline uint stktable_calc_shard_num(const struct stktable *t, const void *key, size_t len)
{
+#if CONFIG_HAP_TBL_BUCKETS > 1
return XXH32(key, len, t->hash_seed) % CONFIG_HAP_TBL_BUCKETS;
+#else
+ return 0;
+#endif
}
/* kill an entry if it's expired and its ref_cnt is zero */
shard = stktable_calc_shard_num(t, ts->key.key, len);
+ /* make the compiler happy when shard is not used without threads */
+ ALREADY_CHECKED(shard);
+
HA_RWLOCK_WRLOCK(STK_TABLE_LOCK, &t->shards[shard].sh_lock);
__stksess_kill_if_expired(t, ts);
HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &t->shards[shard].sh_lock);
shard = stktable_calc_shard_num(t, ts->key.key, len);
+ /* make the compiler happy when shard is not used without threads */
+ ALREADY_CHECKED(shard);
+
HA_RWLOCK_RDLOCK(STK_TABLE_LOCK, &t->shards[shard].sh_lock);
__stksess_free(t, ts);
HA_RWLOCK_RDUNLOCK(STK_TABLE_LOCK, &t->shards[shard].sh_lock);
shard = stktable_calc_shard_num(t, ts->key.key, len);
+ /* make the compiler happy when shard is not used without threads */
+ ALREADY_CHECKED(shard);
+
HA_RWLOCK_WRLOCK(STK_TABLE_LOCK, &t->shards[shard].sh_lock);
ret = __stksess_kill(t, ts);
HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &t->shards[shard].sh_lock);