MINOR: sample: always set a new sample's owner before evaluating it

Some functions like sample_conv_var2smp(), var_get_byname(), and
var_set_byname() directly or indirectly need to access the current
stream and/or session and must find it in the sample itself and not
as a distinct argument. Thus we first need to call smp_set_owner()
prior to each such calls.
This commit is contained in:
Willy Tarreau 2016-03-10 16:28:58 +01:00
parent 1777ea63e0
commit 7560dd4b6a
2 changed files with 10 additions and 0 deletions

View File

@ -4568,6 +4568,7 @@ __LJMP static int hlua_set_var(lua_State *L)
hlua_lua2smp(L, 3, &smp);
/* Store the sample in a variable. */
smp_set_owner(&smp, htxn->p, htxn->s->sess, htxn->s, htxn->dir & SMP_OPT_DIR);
vars_set_by_name(name, len, htxn->s, &smp);
return 0;
}
@ -4587,6 +4588,7 @@ __LJMP static int hlua_get_var(lua_State *L)
htxn = MAY_LJMP(hlua_checktxn(L, 1));
name = MAY_LJMP(luaL_checklstring(L, 2, &len));
smp_set_owner(&smp, htxn->p, htxn->s->sess, htxn->s, htxn->dir & SMP_OPT_DIR);
if (!vars_get_by_name(name, len, htxn->s, &smp)) {
lua_pushnil(L);
return 1;

View File

@ -2100,6 +2100,7 @@ static int sample_conv_binary_and(const struct arg *arg_p, struct sample *smp, v
{
struct sample tmp;
smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt);
if (!sample_conv_var2smp(arg_p, smp->strm, &tmp))
return 0;
smp->data.u.sint &= tmp.data.u.sint;
@ -2113,6 +2114,7 @@ static int sample_conv_binary_or(const struct arg *arg_p, struct sample *smp, vo
{
struct sample tmp;
smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt);
if (!sample_conv_var2smp(arg_p, smp->strm, &tmp))
return 0;
smp->data.u.sint |= tmp.data.u.sint;
@ -2126,6 +2128,7 @@ static int sample_conv_binary_xor(const struct arg *arg_p, struct sample *smp, v
{
struct sample tmp;
smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt);
if (!sample_conv_var2smp(arg_p, smp->strm, &tmp))
return 0;
smp->data.u.sint ^= tmp.data.u.sint;
@ -2165,6 +2168,7 @@ static int sample_conv_arith_add(const struct arg *arg_p, struct sample *smp, vo
{
struct sample tmp;
smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt);
if (!sample_conv_var2smp(arg_p, smp->strm, &tmp))
return 0;
smp->data.u.sint = arith_add(smp->data.u.sint, tmp.data.u.sint);
@ -2179,6 +2183,7 @@ static int sample_conv_arith_sub(const struct arg *arg_p,
{
struct sample tmp;
smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt);
if (!sample_conv_var2smp(arg_p, smp->strm, &tmp))
return 0;
@ -2211,6 +2216,7 @@ static int sample_conv_arith_mul(const struct arg *arg_p,
struct sample tmp;
long long int c;
smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt);
if (!sample_conv_var2smp(arg_p, smp->strm, &tmp))
return 0;
@ -2254,6 +2260,7 @@ static int sample_conv_arith_div(const struct arg *arg_p,
{
struct sample tmp;
smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt);
if (!sample_conv_var2smp(arg_p, smp->strm, &tmp))
return 0;
@ -2281,6 +2288,7 @@ static int sample_conv_arith_mod(const struct arg *arg_p,
{
struct sample tmp;
smp_set_owner(&tmp, smp->px, smp->sess, smp->strm, smp->opt);
if (!sample_conv_var2smp(arg_p, smp->strm, &tmp))
return 0;