MEDIUM: vars: Be able to retrieve variable of the parent stream, if any
It is now possible to retrieved the value of a variable using the parent stream or the parent session instead of the current one. It remains forbidden to set or unset this value. The sample fetch used to store the result is a local copy. So it may be safely altered by a converter without changing the value of the original variable. Note that for now, the parent of a stream is never set. So this part is not really used. This will change with the SPOE.
This commit is contained in:
parent
1a1afecb8b
commit
230c1570ac
13
src/vars.c
13
src/vars.c
|
@ -64,6 +64,13 @@ static inline struct vars *get_vars(struct session *sess, struct stream *strm, c
|
|||
if (!desc)
|
||||
return NULL;
|
||||
|
||||
if (desc->flags & VDF_PARENT_CTX) {
|
||||
if (!strm || !strm->parent)
|
||||
return NULL;
|
||||
strm = strm->parent;
|
||||
sess = strm_sess(strm);
|
||||
}
|
||||
|
||||
switch (desc->scope) {
|
||||
case SCOPE_PROC:
|
||||
return &proc_vars;
|
||||
|
@ -758,9 +765,6 @@ int vars_get_by_name(const char *name, size_t len, struct sample *smp, const str
|
|||
if (!vars_fill_desc(name, len, &desc, NULL))
|
||||
return 0;
|
||||
|
||||
if (desc.flags & VDF_PARENT_CTX)
|
||||
return 0;
|
||||
|
||||
/* Select "vars" pool according with the scope. */
|
||||
vars = get_vars(smp->sess, smp->strm, &desc);
|
||||
if (!vars || vars->scope != desc.scope)
|
||||
|
@ -786,9 +790,6 @@ int vars_get_by_desc(const struct var_desc *var_desc, struct sample *smp, const
|
|||
{
|
||||
struct vars *vars;
|
||||
|
||||
if (var_desc->flags & VDF_PARENT_CTX)
|
||||
return 0;
|
||||
|
||||
/* Select "vars" pool according with the scope. */
|
||||
vars = get_vars(smp->sess, smp->strm, var_desc);
|
||||
|
||||
|
|
Loading…
Reference in New Issue