BUG/MINOR: freq: fix infinite loop on freq_ctr_period.

Using peers or stick table we could update an freq_ctr
using a tick value with the first bit set but this
bit is reserved for lock since multithreading support.
This commit is contained in:
Emeric Brun 2017-11-02 17:32:43 +01:00 committed by Willy Tarreau
parent 4b75fffa2b
commit f2fc1fda80
2 changed files with 11 additions and 2 deletions

View File

@ -1312,7 +1312,12 @@ switchstate:
case STD_T_FRQP: {
struct freq_ctr_period data;
data.curr_tick = tick_add(now_ms, -intdecode(&msg_cur, msg_end));
/* First bit is reserved for the freq_ctr_period lock
Note: here we're still protected by the stksess lock
so we don't need to update the update the freq_ctr_period
using its internal lock */
data.curr_tick = tick_add(now_ms, -intdecode(&msg_cur, msg_end)) & ~0x1;
if (!msg_cur) {
/* malformed message */
RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);

View File

@ -2968,7 +2968,11 @@ static int table_process_entry_per_key(struct appctx *appctx, char **args)
* push measures without having to update them too often.
*/
frqp = &stktable_data_cast(ptr, std_t_frqp);
frqp->curr_tick = now_ms;
/* First bit is reserved for the freq_ctr_period lock
Note: here we're still protected by the stksess lock
so we don't need to update the update the freq_ctr_period
using its internal lock */
frqp->curr_tick = now_ms & ~0x1;
frqp->prev_ctr = 0;
frqp->curr_ctr = value;
break;