From: Thierry FOURNIER Date: Thu, 30 Jul 2015 17:03:55 +0000 (+0200) Subject: MINOR: lua: use the hlua_rule type in place of opaque type X-Git-Tag: v1.6-dev4~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=231ef1d99cb2c5872c0c4a5ddeca9be998e18870;p=thirdparty%2Fhaproxy.git MINOR: lua: use the hlua_rule type in place of opaque type 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. --- diff --git a/include/types/action.h b/include/types/action.h index 3333fb0be4..1cb4aa9148 100644 --- a/include/types/action.h +++ b/include/types/action.h @@ -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 */ diff --git a/include/types/hlua.h b/include/types/hlua.h index 357f7ab138..f481bdfa90 100644 --- a/include/types/hlua.h +++ b/include/types/hlua.h @@ -123,6 +123,7 @@ struct hlua_socket { /* Empty struct for compilation compatibility */ struct hlua { }; struct hlua_socket { }; +struct hlua_rule { }; #endif /* USE_LUA */ diff --git a/src/hlua.c b/src/hlua.c index 26890c2d5e..83c66ae99c 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -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;