mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-05-07 02:08:04 +00:00
MEDIUM: vars: pre-create parsed SCOPE_PROC variables as permanent ones
All variables whose names are parsed by the config parser, the command-line parser or the SPOE's register-var-names parser are now preset as permanent. This will guarantee that these variables will exist through out all the process' life, and that it will be possible to implement the "ifexist" feature by looking them up. This was marked medium because pre-setting a variable with an empty value may always have side effects, even though none was spotted at this stage.
This commit is contained in:
parent
c1c88f4809
commit
df8eeb1619
@ -529,6 +529,7 @@ int vars_check_arg(struct arg *arg, char **err)
|
||||
{
|
||||
char *name;
|
||||
enum vars_scope scope;
|
||||
struct sample empty_smp = { };
|
||||
|
||||
/* Check arg type. */
|
||||
if (arg->type != ARGT_STR) {
|
||||
@ -543,6 +544,9 @@ int vars_check_arg(struct arg *arg, char **err)
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
if (scope == SCOPE_PROC && !var_set(name, scope, &empty_smp, VF_CREATEONLY|VF_PERMANENT))
|
||||
return 0;
|
||||
|
||||
/* properly destroy the chunk */
|
||||
chunk_destroy(&arg->data.str);
|
||||
|
||||
@ -823,6 +827,7 @@ static enum act_parse_ret parse_store(const char **args, int *arg, struct proxy
|
||||
int var_len;
|
||||
const char *kw_name;
|
||||
int flags, set_var = 0; /* 0=unset-var, 1=set-var, 2=set-var-fmt */
|
||||
struct sample empty_smp = { };
|
||||
|
||||
if (strncmp(var_name, "set-var-fmt", 11) == 0) {
|
||||
var_name += 11;
|
||||
@ -856,6 +861,10 @@ static enum act_parse_ret parse_store(const char **args, int *arg, struct proxy
|
||||
if (!rule->arg.vars.name)
|
||||
return ACT_RET_PRS_ERR;
|
||||
|
||||
if (rule->arg.vars.scope == SCOPE_PROC &&
|
||||
!var_set(rule->arg.vars.name, rule->arg.vars.scope, &empty_smp, VF_CREATEONLY|VF_PERMANENT))
|
||||
return 0;
|
||||
|
||||
/* There is no fetch method when variable is unset. Just set the right
|
||||
* action and return. */
|
||||
if (!set_var) {
|
||||
|
Loading…
Reference in New Issue
Block a user