]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: lua: Add flags on the lua TXN to know the execution context
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Aug 2021 14:29:41 +0000 (16:29 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 12 Aug 2021 06:57:07 +0000 (08:57 +0200)
A lua TXN can be created when a sample fetch, an action or a filter callback
function is executed. A flag is now used to track the execute context.
Respectively, HLUA_TXN_SMP_CTX, HLUA_TXN_ACT_CTX and HLUA_TXN_FLT_CTX. The
filter flag is not used for now.

include/haproxy/hlua-t.h
src/hlua.c

index 775c8535e4472675376221c6312de7268dfc3036..2c6cbd81157d6a3ebea13b88b1052836f15aeb38 100644 (file)
@@ -64,6 +64,12 @@ struct stream;
 #define HLUA_F_MAY_USE_HTTP 0x02
 
 #define HLUA_TXN_NOTERM   0x00000001
+/* 0x00000002 .. 0x00000008 unsued */
+#define HLUA_TXN_SMP_CTX  0x00000010 /* Executed from a sample fecth context */
+#define HLUA_TXN_ACT_CTX  0x00000020 /* Executed from a action context */
+#define HLUA_TXN_FLT_CTX  0x00000030 /* Executed from a filter context */
+#define HLUA_TXN_CTX_MASK 0x00000030 /* Mask to get the execution context */
+
 
 #define HLUA_CONCAT_BLOCSZ 2048
 
index f2ed684a3b8770118d4e78e81c9d21034f866140..7f0aa9b2d8c732ee97e2b45e17697acedb3843aa 100644 (file)
@@ -6936,7 +6936,7 @@ static int hlua_sample_fetch_wrapper(const struct arg *arg_p, struct sample *smp
        struct hlua_function *fcn = private;
        struct stream *stream = smp->strm;
        const char *error;
-       unsigned int hflags = HLUA_TXN_NOTERM;
+       unsigned int hflags = HLUA_TXN_NOTERM | HLUA_TXN_SMP_CTX;
 
        if (!stream)
                return 0;
@@ -7254,7 +7254,7 @@ static enum act_return hlua_action(struct act_rule *rule, struct proxy *px,
                                    struct session *sess, struct stream *s, int flags)
 {
        char **arg;
-       unsigned int hflags = 0;
+       unsigned int hflags = HLUA_TXN_ACT_CTX;
        int dir, act_ret = ACT_RET_CONT;
        const char *error;