mirror of
https://github.com/haproxy/haproxy.git
synced 2026-05-27 11:52:34 -04:00
CLEANUP: stick-table: uniformize the different action_inc_gpc*()
Some checks failed
Contrib / admin/halog/ (push) Has been cancelled
Contrib / dev/flags/ (push) Has been cancelled
Contrib / dev/haring/ (push) Has been cancelled
Contrib / dev/hpack/ (push) Has been cancelled
Contrib / dev/poll/ (push) Has been cancelled
VTest / Generate Build Matrix (push) Has been cancelled
Windows / Windows, gcc, all features (push) Has been cancelled
VTest / (push) Has been cancelled
Some checks failed
Contrib / admin/halog/ (push) Has been cancelled
Contrib / dev/flags/ (push) Has been cancelled
Contrib / dev/haring/ (push) Has been cancelled
Contrib / dev/hpack/ (push) Has been cancelled
Contrib / dev/poll/ (push) Has been cancelled
VTest / Generate Build Matrix (push) Has been cancelled
Windows / Windows, gcc, all features (push) Has been cancelled
VTest / (push) Has been cancelled
While action_inc_gpc1() explicitly checks if s->stkctr or sess->stkctr
are set since 2.8 with commit 6c0117168 ("MEDIUM: stick-table: set the
track-sc limit at boottime via tune.stick-counters"), action_inc_gpc0()
and the generic action_inc_gpc() still stuck to the old approach of not
checking them, causing confusion when reviewing the code.
Upon closer inspection, the only case where the pointer may be NULL is
when global.tune.nb_stk_ctr is zero, which happens when the global
section contains "tune.stick-counters 0". However in this case, the
config parser "parse_inc_gpc()" will reject any reference to any stick
counter, so in theory there is no problem.
Regardless, the difference of treatment between sibling functions remains
confusing and the check is cheap, so let's generalize it, it will save a
future reader from the need to inspect stream_new() and session_new().
This commit is contained in:
parent
015933794e
commit
b44d60eb42
1 changed files with 8 additions and 4 deletions
|
|
@ -2675,10 +2675,12 @@ static enum act_return action_inc_gpc(struct act_rule *rule, struct proxy *px,
|
|||
struct stkctr *stkctr;
|
||||
|
||||
/* Extract the stksess, return OK if no stksess available. */
|
||||
if (s)
|
||||
if (s && s->stkctr)
|
||||
stkctr = &s->stkctr[rule->arg.gpc.sc];
|
||||
else
|
||||
else if (sess->stkctr)
|
||||
stkctr = &sess->stkctr[rule->arg.gpc.sc];
|
||||
else
|
||||
return ACT_RET_CONT;
|
||||
|
||||
ts = stkctr_entry(stkctr);
|
||||
if (ts) {
|
||||
|
|
@ -2716,10 +2718,12 @@ static enum act_return action_inc_gpc0(struct act_rule *rule, struct proxy *px,
|
|||
unsigned int period = 0;
|
||||
|
||||
/* Extract the stksess, return OK if no stksess available. */
|
||||
if (s)
|
||||
if (s && s->stkctr)
|
||||
stkctr = &s->stkctr[rule->arg.gpc.sc];
|
||||
else
|
||||
else if (sess->stkctr)
|
||||
stkctr = &sess->stkctr[rule->arg.gpc.sc];
|
||||
else
|
||||
return ACT_RET_CONT;
|
||||
|
||||
ts = stkctr_entry(stkctr);
|
||||
if (ts) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue