MINOR: vars: remove the emptiness tests in callers before pruning
All callers of vars_prune_* currently check the list for emptiness. Let's leave that to vars_prune() itself, it will ease some changes in the code. Thanks to the previous inlining of the vars_prune() function, there's no performance loss, and even a very tiny 0.1% gain.
This commit is contained in:
parent
2c1a9c3a43
commit
6e92988e20
@ -85,6 +85,9 @@ static inline void vars_prune(struct vars *vars, struct session *sess, struct st
|
||||
size += var_clear(var, 1);
|
||||
}
|
||||
|
||||
if (!size)
|
||||
return;
|
||||
|
||||
var_accounting_diff(vars, sess, strm, -size);
|
||||
}
|
||||
|
||||
|
@ -2967,8 +2967,7 @@ int http_eval_after_res_rules(struct stream *s)
|
||||
|
||||
/* prune the request variables if not already done and swap to the response variables. */
|
||||
if (s->vars_reqres.scope != SCOPE_RES) {
|
||||
if (!LIST_ISEMPTY(&s->vars_reqres.head))
|
||||
vars_prune(&s->vars_reqres, s->sess, s);
|
||||
vars_prune(&s->vars_reqres, s->sess, s);
|
||||
vars_init_head(&s->vars_reqres, SCOPE_RES);
|
||||
}
|
||||
|
||||
@ -5094,10 +5093,8 @@ void http_destroy_txn(struct stream *s)
|
||||
txn->srv_cookie = NULL;
|
||||
txn->cli_cookie = NULL;
|
||||
|
||||
if (!LIST_ISEMPTY(&s->vars_txn.head))
|
||||
vars_prune(&s->vars_txn, s->sess, s);
|
||||
if (!LIST_ISEMPTY(&s->vars_reqres.head))
|
||||
vars_prune(&s->vars_reqres, s->sess, s);
|
||||
vars_prune(&s->vars_txn, s->sess, s);
|
||||
vars_prune(&s->vars_reqres, s->sess, s);
|
||||
|
||||
b_free(&txn->l7_buffer);
|
||||
|
||||
|
@ -695,10 +695,8 @@ void stream_free(struct stream *s)
|
||||
}
|
||||
|
||||
/* Cleanup all variable contexts. */
|
||||
if (!LIST_ISEMPTY(&s->vars_txn.head))
|
||||
vars_prune(&s->vars_txn, s->sess, s);
|
||||
if (!LIST_ISEMPTY(&s->vars_reqres.head))
|
||||
vars_prune(&s->vars_reqres, s->sess, s);
|
||||
vars_prune(&s->vars_txn, s->sess, s);
|
||||
vars_prune(&s->vars_reqres, s->sess, s);
|
||||
|
||||
stream_store_counters(s);
|
||||
pool_free(pool_head_stk_ctr, s->stkctr);
|
||||
@ -2309,8 +2307,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
if (sc_state_in(scb->state, SC_SB_REQ|SC_SB_QUE|SC_SB_TAR|SC_SB_ASS)) {
|
||||
/* prune the request variables and swap to the response variables. */
|
||||
if (s->vars_reqres.scope != SCOPE_RES) {
|
||||
if (!LIST_ISEMPTY(&s->vars_reqres.head))
|
||||
vars_prune(&s->vars_reqres, s->sess, s);
|
||||
vars_prune(&s->vars_reqres, s->sess, s);
|
||||
vars_init_head(&s->vars_reqres, SCOPE_RES);
|
||||
}
|
||||
|
||||
|
@ -207,6 +207,9 @@ void vars_prune_per_sess(struct vars *vars)
|
||||
size += var_clear(var, 1);
|
||||
}
|
||||
|
||||
if (!size)
|
||||
return;
|
||||
|
||||
if (var_sess_limit)
|
||||
_HA_ATOMIC_SUB(&vars->size, size);
|
||||
if (var_proc_limit || var_global_limit)
|
||||
|
Loading…
x
Reference in New Issue
Block a user