]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: lua: use the hlua_rule type in place of opaque type
authorThierry FOURNIER <tfournier@arpalert.org>
Thu, 30 Jul 2015 17:03:55 +0000 (19:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 20 Aug 2015 15:13:46 +0000 (17:13 +0200)
The (http|tcp)-(request|response) action rules use common
opaque type. For the HAProxy embbedded feature, types are know,
it better to add this types in the action union and use it.

include/types/action.h
include/types/hlua.h
src/hlua.c

index 3333fb0be41caa09751c9b636270236088844fce..1cb4aa9148079841fb0e077aa1865c4fad4b05ce 100644 (file)
@@ -56,6 +56,7 @@ struct act_rule {
                        struct list key;       /* pattern to retrieve MAP or ACL key */
                        struct list value;     /* pattern to retrieve MAP value */
                } map;
+               struct hlua_rule *hlua_rule;
                struct {
                        void *p[4];
                } act;                         /* generic pointers to be used by custom actions */
index 357f7ab1380a01cfb32ba75eec5d5b5288b0d0ec..f481bdfa9033d430a0ae8fe84ea05868fd23d32b 100644 (file)
@@ -123,6 +123,7 @@ struct hlua_socket {
 /* Empty struct for compilation compatibility */
 struct hlua { };
 struct hlua_socket { };
+struct hlua_rule { };
 
 #endif /* USE_LUA */
 
index 26890c2d5eb32a4d7cc360037c0a4f3f7bfeddfb..83c66ae99c38ef3d93bd6bfdacdd7be29576aa2f 100644 (file)
@@ -4382,8 +4382,7 @@ static int hlua_request_act_wrapper(struct hlua_rule *rule, struct proxy *px,
 int hlua_tcp_req_act_wrapper(struct act_rule *act_rule, struct proxy *px,
                              struct session *sess, struct stream *s)
 {
-       return hlua_request_act_wrapper((struct hlua_rule *)act_rule->arg.act.p[0],
-                                       px, s, AN_REQ_INSPECT_FE);
+       return hlua_request_act_wrapper(act_rule->arg.hlua_rule, px, s, AN_REQ_INSPECT_FE);
 }
 
 /* Lua execution wrapper for "tcp-response". This function uses
@@ -4392,8 +4391,7 @@ int hlua_tcp_req_act_wrapper(struct act_rule *act_rule, struct proxy *px,
 int hlua_tcp_res_act_wrapper(struct act_rule *act_rule, struct proxy *px,
                              struct session *sess, struct stream *s)
 {
-       return hlua_request_act_wrapper((struct hlua_rule *)act_rule->arg.act.p[0],
-                                       px, s, AN_RES_INSPECT);
+       return hlua_request_act_wrapper(act_rule->arg.hlua_rule, px, s, AN_RES_INSPECT);
 }
 
 /* Lua execution wrapper for http-request.
@@ -4403,8 +4401,7 @@ int hlua_tcp_res_act_wrapper(struct act_rule *act_rule, struct proxy *px,
 int hlua_http_req_act_wrapper(struct act_rule *rule, struct proxy *px,
                               struct session *sess, struct stream *s)
 {
-       return hlua_request_act_wrapper((struct hlua_rule *)rule->arg.act.p[0], px,
-                                       s, AN_REQ_HTTP_PROCESS_FE);
+       return hlua_request_act_wrapper(rule->arg.hlua_rule, px, s, AN_REQ_HTTP_PROCESS_FE);
 }
 
 /* Lua execution wrapper for http-response.
@@ -4414,15 +4411,14 @@ int hlua_http_req_act_wrapper(struct act_rule *rule, struct proxy *px,
 int hlua_http_res_act_wrapper(struct act_rule *rule, struct proxy *px,
                               struct session *sess, struct stream *s)
 {
-       return hlua_request_act_wrapper((struct hlua_rule *)rule->arg.act.p[0], px,
-                                       s, AN_RES_HTTP_PROCESS_BE);
+       return hlua_request_act_wrapper(rule->arg.hlua_rule, px, s, AN_RES_HTTP_PROCESS_BE);
 }
 
 /* tcp-request <*> configuration wrapper. */
 static int tcp_req_action_register_lua(const char **args, int *cur_arg, struct proxy *px,
                                        struct act_rule *rule, char **err)
 {
-       if (!hlua_parse_rule(args, cur_arg, px, (struct hlua_rule **)&rule->arg.act.p[0], err))
+       if (!hlua_parse_rule(args, cur_arg, px, &rule->arg.hlua_rule, err))
                return 0;
        rule->action = TCP_ACT_CUSTOM_CONT;
        rule->action_ptr = hlua_tcp_req_act_wrapper;
@@ -4433,7 +4429,7 @@ static int tcp_req_action_register_lua(const char **args, int *cur_arg, struct p
 static int tcp_res_action_register_lua(const char **args, int *cur_arg, struct proxy *px,
                                        struct act_rule *rule, char **err)
 {
-       if (!hlua_parse_rule(args, cur_arg, px, (struct hlua_rule **)&rule->arg.act.p[0], err))
+       if (!hlua_parse_rule(args, cur_arg, px, &rule->arg.hlua_rule, err))
                return 0;
        rule->action = TCP_ACT_CUSTOM_CONT;
        rule->action_ptr = hlua_tcp_res_act_wrapper;
@@ -4444,7 +4440,7 @@ static int tcp_res_action_register_lua(const char **args, int *cur_arg, struct p
 static int http_req_action_register_lua(const char **args, int *cur_arg, struct proxy *px,
                                         struct act_rule *rule, char **err)
 {
-       if (!hlua_parse_rule(args, cur_arg, px, (struct hlua_rule **)&rule->arg.act.p[0], err))
+       if (!hlua_parse_rule(args, cur_arg, px, &rule->arg.hlua_rule, err))
                return -1;
        rule->action = HTTP_REQ_ACT_CUSTOM_CONT;
        rule->action_ptr = hlua_http_req_act_wrapper;
@@ -4455,7 +4451,7 @@ static int http_req_action_register_lua(const char **args, int *cur_arg, struct
 static int http_res_action_register_lua(const char **args, int *cur_arg, struct proxy *px,
                                         struct act_rule *rule, char **err)
 {
-       if (!hlua_parse_rule(args, cur_arg, px, (struct hlua_rule **)&rule->arg.act.p[0], err))
+       if (!hlua_parse_rule(args, cur_arg, px, &rule->arg.hlua_rule, err))
                return -1;
        rule->action = HTTP_RES_ACT_CUSTOM_CONT;
        rule->action_ptr = hlua_http_res_act_wrapper;