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.
This commit is contained in:
Thierry FOURNIER 2015-07-30 19:03:55 +02:00 committed by Willy Tarreau
parent 7677f400f5
commit 231ef1d99c
3 changed files with 10 additions and 12 deletions

View 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 */

View File

@ -123,6 +123,7 @@ struct hlua_socket {
/* Empty struct for compilation compatibility */
struct hlua { };
struct hlua_socket { };
struct hlua_rule { };
#endif /* USE_LUA */

View 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;