mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-22 06:55:53 +00:00
REORG: global: move free acl/action in their related source files
Move deinit_acl_cond and deinit_act_rules from haproxy.c respectively in acl.c and action.c. The name of the functions has been slightly altered, replacing the prefix deinit_* by free_* to reflect their purpose more clearly. This change has been made in preparation to the implementation of a free proxy function. As a side-effect, it helps to clean up haproxy.c.
This commit is contained in:
parent
ce44482fe5
commit
68fd7e43d3
@ -146,6 +146,7 @@ void acl_unregister_keywords(struct acl_kw_list *kwl);
|
|||||||
*/
|
*/
|
||||||
int init_acl();
|
int init_acl();
|
||||||
|
|
||||||
|
void free_acl_cond(struct acl_cond *cond);
|
||||||
|
|
||||||
#endif /* _HAPROXY_ACL_H */
|
#endif /* _HAPROXY_ACL_H */
|
||||||
|
|
||||||
|
@ -102,4 +102,6 @@ static inline void release_timeout_action(struct act_rule *rule)
|
|||||||
release_sample_expr(rule->arg.timeout.expr);
|
release_sample_expr(rule->arg.timeout.expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void free_act_rules(struct list *rules);
|
||||||
|
|
||||||
#endif /* _HAPROXY_ACTION_H */
|
#endif /* _HAPROXY_ACTION_H */
|
||||||
|
20
src/acl.c
20
src/acl.c
@ -1302,6 +1302,26 @@ int init_acl()
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void free_acl_cond(struct acl_cond *cond)
|
||||||
|
{
|
||||||
|
struct acl_term_suite *suite, *suiteb;
|
||||||
|
struct acl_term *term, *termb;
|
||||||
|
|
||||||
|
if (!cond)
|
||||||
|
return;
|
||||||
|
|
||||||
|
list_for_each_entry_safe(suite, suiteb, &cond->suites, list) {
|
||||||
|
list_for_each_entry_safe(term, termb, &suite->terms, list) {
|
||||||
|
LIST_DEL(&term->list);
|
||||||
|
free(term);
|
||||||
|
}
|
||||||
|
LIST_DEL(&suite->list);
|
||||||
|
free(suite);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(cond);
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* All supported sample and ACL keywords must be declared here. */
|
/* All supported sample and ACL keywords must be declared here. */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
14
src/action.c
14
src/action.c
@ -10,6 +10,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <haproxy/acl.h>
|
||||||
#include <haproxy/action.h>
|
#include <haproxy/action.h>
|
||||||
#include <haproxy/api.h>
|
#include <haproxy/api.h>
|
||||||
#include <haproxy/errors.h>
|
#include <haproxy/errors.h>
|
||||||
@ -259,3 +260,16 @@ const char *action_suggest(const char *word, const struct list *keywords, const
|
|||||||
|
|
||||||
return best_ptr;
|
return best_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void free_act_rules(struct list *rules)
|
||||||
|
{
|
||||||
|
struct act_rule *rule, *ruleb;
|
||||||
|
|
||||||
|
list_for_each_entry_safe(rule, ruleb, rules, list) {
|
||||||
|
LIST_DEL(&rule->list);
|
||||||
|
free_acl_cond(rule->cond);
|
||||||
|
if (rule->release_ptr)
|
||||||
|
rule->release_ptr(rule);
|
||||||
|
free(rule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
#include <import/sha1.h>
|
#include <import/sha1.h>
|
||||||
|
|
||||||
#include <haproxy/acl.h>
|
#include <haproxy/acl.h>
|
||||||
|
#include <haproxy/action.h>
|
||||||
#include <haproxy/activity.h>
|
#include <haproxy/activity.h>
|
||||||
#include <haproxy/api.h>
|
#include <haproxy/api.h>
|
||||||
#include <haproxy/arg.h>
|
#include <haproxy/arg.h>
|
||||||
@ -2135,46 +2136,13 @@ static void init(int argc, char **argv)
|
|||||||
free(err_msg);
|
free(err_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deinit_acl_cond(struct acl_cond *cond)
|
|
||||||
{
|
|
||||||
struct acl_term_suite *suite, *suiteb;
|
|
||||||
struct acl_term *term, *termb;
|
|
||||||
|
|
||||||
if (!cond)
|
|
||||||
return;
|
|
||||||
|
|
||||||
list_for_each_entry_safe(suite, suiteb, &cond->suites, list) {
|
|
||||||
list_for_each_entry_safe(term, termb, &suite->terms, list) {
|
|
||||||
LIST_DEL(&term->list);
|
|
||||||
free(term);
|
|
||||||
}
|
|
||||||
LIST_DEL(&suite->list);
|
|
||||||
free(suite);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void deinit_act_rules(struct list *rules)
|
|
||||||
{
|
|
||||||
struct act_rule *rule, *ruleb;
|
|
||||||
|
|
||||||
list_for_each_entry_safe(rule, ruleb, rules, list) {
|
|
||||||
LIST_DEL(&rule->list);
|
|
||||||
deinit_acl_cond(rule->cond);
|
|
||||||
if (rule->release_ptr)
|
|
||||||
rule->release_ptr(rule);
|
|
||||||
free(rule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void deinit_stick_rules(struct list *rules)
|
static void deinit_stick_rules(struct list *rules)
|
||||||
{
|
{
|
||||||
struct sticking_rule *rule, *ruleb;
|
struct sticking_rule *rule, *ruleb;
|
||||||
|
|
||||||
list_for_each_entry_safe(rule, ruleb, rules, list) {
|
list_for_each_entry_safe(rule, ruleb, rules, list) {
|
||||||
LIST_DEL(&rule->list);
|
LIST_DEL(&rule->list);
|
||||||
deinit_acl_cond(rule->cond);
|
free_acl_cond(rule->cond);
|
||||||
release_sample_expr(rule->expr);
|
release_sample_expr(rule->expr);
|
||||||
free(rule);
|
free(rule);
|
||||||
}
|
}
|
||||||
@ -2367,13 +2335,13 @@ void deinit(void)
|
|||||||
free(lf);
|
free(lf);
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit_act_rules(&p->tcp_req.inspect_rules);
|
free_act_rules(&p->tcp_req.inspect_rules);
|
||||||
deinit_act_rules(&p->tcp_rep.inspect_rules);
|
free_act_rules(&p->tcp_rep.inspect_rules);
|
||||||
deinit_act_rules(&p->tcp_req.l4_rules);
|
free_act_rules(&p->tcp_req.l4_rules);
|
||||||
deinit_act_rules(&p->tcp_req.l5_rules);
|
free_act_rules(&p->tcp_req.l5_rules);
|
||||||
deinit_act_rules(&p->http_req_rules);
|
free_act_rules(&p->http_req_rules);
|
||||||
deinit_act_rules(&p->http_res_rules);
|
free_act_rules(&p->http_res_rules);
|
||||||
deinit_act_rules(&p->http_after_res_rules);
|
free_act_rules(&p->http_after_res_rules);
|
||||||
|
|
||||||
deinit_stick_rules(&p->storersp_rules);
|
deinit_stick_rules(&p->storersp_rules);
|
||||||
deinit_stick_rules(&p->sticking_rules);
|
deinit_stick_rules(&p->sticking_rules);
|
||||||
@ -2461,7 +2429,7 @@ void deinit(void)
|
|||||||
free(uap->desc);
|
free(uap->desc);
|
||||||
|
|
||||||
userlist_free(uap->userlist);
|
userlist_free(uap->userlist);
|
||||||
deinit_act_rules(&uap->http_req_rules);
|
free_act_rules(&uap->http_req_rules);
|
||||||
|
|
||||||
scope = uap->scope;
|
scope = uap->scope;
|
||||||
while (scope) {
|
while (scope) {
|
||||||
|
Loading…
Reference in New Issue
Block a user