MINOR: proxy: add http_free_redirect_rule() function
Adding http_free_redirect_rule() function to free a single redirect rule since it may be required to free rules outside of free_proxy() function. This patch is required for an upcoming bugfix. [for 2.2, free_proxy function did not exist (first seen in 2.4), thus http_free_redirect_rule() needs to be deducted from haproxy.c deinit() function if the patch is required]
This commit is contained in:
parent
8dfc2491d2
commit
7abc9224a6
|
@ -34,6 +34,7 @@ extern struct action_kw_list http_after_res_keywords;
|
||||||
struct act_rule *parse_http_req_cond(const char **args, const char *file, int linenum, struct proxy *proxy);
|
struct act_rule *parse_http_req_cond(const char **args, const char *file, int linenum, struct proxy *proxy);
|
||||||
struct act_rule *parse_http_res_cond(const char **args, const char *file, int linenum, struct proxy *proxy);
|
struct act_rule *parse_http_res_cond(const char **args, const char *file, int linenum, struct proxy *proxy);
|
||||||
struct act_rule *parse_http_after_res_cond(const char **args, const char *file, int linenum, struct proxy *proxy);
|
struct act_rule *parse_http_after_res_cond(const char **args, const char *file, int linenum, struct proxy *proxy);
|
||||||
|
void http_free_redirect_rule(struct redirect_rule *rdr);
|
||||||
struct redirect_rule *http_parse_redirect_rule(const char *file, int linenum, struct proxy *curproxy,
|
struct redirect_rule *http_parse_redirect_rule(const char *file, int linenum, struct proxy *curproxy,
|
||||||
const char **args, char **errmsg, int use_fmt, int dir);
|
const char **args, char **errmsg, int use_fmt, int dir);
|
||||||
|
|
||||||
|
|
|
@ -317,6 +317,26 @@ struct act_rule *parse_http_after_res_cond(const char **args, const char *file,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* completely free redirect rule */
|
||||||
|
void http_free_redirect_rule(struct redirect_rule *rdr)
|
||||||
|
{
|
||||||
|
struct logformat_node *lf, *lfb;
|
||||||
|
|
||||||
|
if (rdr->cond) {
|
||||||
|
prune_acl_cond(rdr->cond);
|
||||||
|
free(rdr->cond);
|
||||||
|
}
|
||||||
|
free(rdr->rdr_str);
|
||||||
|
free(rdr->cookie_str);
|
||||||
|
list_for_each_entry_safe(lf, lfb, &rdr->rdr_fmt, list) {
|
||||||
|
LIST_DELETE(&lf->list);
|
||||||
|
release_sample_expr(lf->expr);
|
||||||
|
free(lf->arg);
|
||||||
|
free(lf);
|
||||||
|
}
|
||||||
|
free(rdr);
|
||||||
|
}
|
||||||
|
|
||||||
/* Parses a redirect rule. Returns the redirect rule on success or NULL on error,
|
/* Parses a redirect rule. Returns the redirect rule on success or NULL on error,
|
||||||
* with <err> filled with the error message. If <use_fmt> is not null, builds a
|
* with <err> filled with the error message. If <use_fmt> is not null, builds a
|
||||||
* dynamic log-format rule instead of a static string. Parameter <dir> indicates
|
* dynamic log-format rule instead of a static string. Parameter <dir> indicates
|
||||||
|
|
15
src/proxy.c
15
src/proxy.c
|
@ -32,6 +32,7 @@
|
||||||
#include <haproxy/http_ana.h>
|
#include <haproxy/http_ana.h>
|
||||||
#include <haproxy/http_htx.h>
|
#include <haproxy/http_htx.h>
|
||||||
#include <haproxy/http_ext.h>
|
#include <haproxy/http_ext.h>
|
||||||
|
#include <haproxy/http_rules.h>
|
||||||
#include <haproxy/listener.h>
|
#include <haproxy/listener.h>
|
||||||
#include <haproxy/log.h>
|
#include <haproxy/log.h>
|
||||||
#include <haproxy/obj_type-t.h>
|
#include <haproxy/obj_type-t.h>
|
||||||
|
@ -238,19 +239,7 @@ void free_proxy(struct proxy *p)
|
||||||
|
|
||||||
list_for_each_entry_safe(rdr, rdrb, &p->redirect_rules, list) {
|
list_for_each_entry_safe(rdr, rdrb, &p->redirect_rules, list) {
|
||||||
LIST_DELETE(&rdr->list);
|
LIST_DELETE(&rdr->list);
|
||||||
if (rdr->cond) {
|
http_free_redirect_rule(rdr);
|
||||||
prune_acl_cond(rdr->cond);
|
|
||||||
free(rdr->cond);
|
|
||||||
}
|
|
||||||
free(rdr->rdr_str);
|
|
||||||
free(rdr->cookie_str);
|
|
||||||
list_for_each_entry_safe(lf, lfb, &rdr->rdr_fmt, list) {
|
|
||||||
LIST_DELETE(&lf->list);
|
|
||||||
release_sample_expr(lf->expr);
|
|
||||||
free(lf->arg);
|
|
||||||
free(lf);
|
|
||||||
}
|
|
||||||
free(rdr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
list_for_each_entry_safe(log, logb, &p->logsrvs, list) {
|
list_for_each_entry_safe(log, logb, &p->logsrvs, list) {
|
||||||
|
|
Loading…
Reference in New Issue