BUILD: stick-tables: silence build warnings when threads are disabled
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.
This commit is contained in:
parent
589fb12904
commit
19f8762a98
@ -199,7 +199,11 @@ static inline void *stktable_data_ptr_idx(struct stktable *t, struct stksess *ts
|
||||
*/
|
||||
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 */
|
||||
@ -227,6 +231,9 @@ static inline void stksess_kill_if_expired(struct stktable *t, struct stksess *t
|
||||
|
||||
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);
|
||||
|
@ -127,6 +127,9 @@ void stksess_free(struct stktable *t, struct stksess *ts)
|
||||
|
||||
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);
|
||||
@ -173,6 +176,9 @@ int stksess_kill(struct stktable *t, struct stksess *ts, int decrefcnt)
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user