static inline void stksess_kill_if_expired(struct stktable *t, struct stksess *ts, int decrefcnt)
{
- HA_RWLOCK_WRLOCK(STK_TABLE_LOCK, &t->lock);
- if (decrefcnt)
- ts->ref_cnt--;
+ if (t->expire != TICK_ETERNITY && tick_is_expired(ts->expire, now_ms)) {
+ HA_RWLOCK_WRLOCK(STK_TABLE_LOCK, &t->lock);
+ if (decrefcnt)
+ ts->ref_cnt--;
- if (t->expire != TICK_ETERNITY && tick_is_expired(ts->expire, now_ms))
__stksess_kill_if_expired(t, ts);
-
- HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &t->lock);
+ HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &t->lock);
+ }
+ else {
+ if (decrefcnt) {
+ HA_RWLOCK_RDLOCK(STK_TABLE_LOCK, &t->lock);
+ HA_ATOMIC_DEC(&ts->ref_cnt);
+ HA_RWLOCK_RDUNLOCK(STK_TABLE_LOCK, &t->lock);
+ }
+ }
}
/* sets the stick counter's entry pointer */
dict_entry_unref(&server_key_dict, stktable_data_cast(data, std_t_dict));
stktable_data_cast(data, std_t_dict) = NULL;
}
- HA_RWLOCK_WRLOCK(STK_TABLE_LOCK, &t->lock);
+ HA_RWLOCK_RDLOCK(STK_TABLE_LOCK, &t->lock);
__stksess_free(t, ts);
- HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &t->lock);
+ HA_RWLOCK_RDUNLOCK(STK_TABLE_LOCK, &t->lock);
}
/*