]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sample: always set a new sample's owner before evaluating it
authorWilly Tarreau <w@1wt.eu>
Thu, 10 Mar 2016 15:28:58 +0000 (16:28 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 10 Mar 2016 15:42:58 +0000 (16:42 +0100)
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.

src/hlua.c
src/sample.c

index 2ed6f525d7f301c516b0335b1c0d39e71a351322..584ad9b346deeccb93b47e333be349b8950bc441 100644 (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;
index 7c2d9058f00035f87785b151586140bd0bafbe2f..6dc62fbc2fcf0d7b778ff8f3684487aeab240982 100644 (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;