mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-12-08 11:11:01 +01:00
MINOR: uri_auth: add stats_uri_auth_free helper
Let's now leverage stats_uri_auth_free() helper to free uri_auth struct instead of manually performing the cleanup, which is error-prone.
This commit is contained in:
parent
350a3ab052
commit
e1ec37ea51
@ -33,6 +33,7 @@ struct uri_auth *stats_add_auth(struct uri_auth **root, char *user);
|
|||||||
struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope);
|
struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope);
|
||||||
struct uri_auth *stats_set_node(struct uri_auth **root, char *name);
|
struct uri_auth *stats_set_node(struct uri_auth **root, char *name);
|
||||||
struct uri_auth *stats_set_desc(struct uri_auth **root, char *desc);
|
struct uri_auth *stats_set_desc(struct uri_auth **root, char *desc);
|
||||||
|
void stats_uri_auth_free(struct uri_auth *uri_auth);
|
||||||
|
|
||||||
#endif /* _HAPROXY_URI_AUTH_H */
|
#endif /* _HAPROXY_URI_AUTH_H */
|
||||||
|
|
||||||
|
|||||||
@ -3283,35 +3283,9 @@ void deinit(void)
|
|||||||
proxy_destroy_all_unref_defaults();
|
proxy_destroy_all_unref_defaults();
|
||||||
|
|
||||||
while (ua) {
|
while (ua) {
|
||||||
struct stat_scope *scope, *scopep;
|
|
||||||
struct stats_admin_rule *rule, *ruleb;
|
|
||||||
|
|
||||||
uap = ua;
|
uap = ua;
|
||||||
ua = ua->next;
|
ua = ua->next;
|
||||||
|
stats_uri_auth_free(uap);
|
||||||
free(uap->uri_prefix);
|
|
||||||
free(uap->auth_realm);
|
|
||||||
free(uap->node);
|
|
||||||
free(uap->desc);
|
|
||||||
|
|
||||||
userlist_free(uap->userlist);
|
|
||||||
free_act_rules(&uap->http_req_rules);
|
|
||||||
list_for_each_entry_safe(rule, ruleb, &uap->admin_rules, list) {
|
|
||||||
LIST_DELETE(&rule->list);
|
|
||||||
free_acl_cond(rule->cond);
|
|
||||||
free(rule);
|
|
||||||
}
|
|
||||||
|
|
||||||
scope = uap->scope;
|
|
||||||
while (scope) {
|
|
||||||
scopep = scope;
|
|
||||||
scope = scope->next;
|
|
||||||
|
|
||||||
free(scopep->px_id);
|
|
||||||
free(scopep);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(uap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
userlist_free(userlist);
|
userlist_free(userlist);
|
||||||
|
|||||||
@ -13,7 +13,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <haproxy/acl.h>
|
||||||
|
#include <haproxy/action.h>
|
||||||
#include <haproxy/api.h>
|
#include <haproxy/api.h>
|
||||||
|
#include <haproxy/auth.h>
|
||||||
#include <haproxy/base64.h>
|
#include <haproxy/base64.h>
|
||||||
#include <haproxy/errors.h>
|
#include <haproxy/errors.h>
|
||||||
#include <haproxy/list.h>
|
#include <haproxy/list.h>
|
||||||
@ -310,6 +313,35 @@ struct uri_auth *stats_add_scope(struct uri_auth **root, char *scope)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stats_uri_auth_free(struct uri_auth *uri_auth)
|
||||||
|
{
|
||||||
|
struct stat_scope *scope, *scopep;
|
||||||
|
struct stats_admin_rule *rule, *ruleb;
|
||||||
|
|
||||||
|
free(uri_auth->uri_prefix);
|
||||||
|
free(uri_auth->auth_realm);
|
||||||
|
free(uri_auth->node);
|
||||||
|
free(uri_auth->desc);
|
||||||
|
|
||||||
|
userlist_free(uri_auth->userlist);
|
||||||
|
free_act_rules(&uri_auth->http_req_rules);
|
||||||
|
list_for_each_entry_safe(rule, ruleb, &uri_auth->admin_rules, list) {
|
||||||
|
LIST_DELETE(&rule->list);
|
||||||
|
free_acl_cond(rule->cond);
|
||||||
|
free(rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
scope = uri_auth->scope;
|
||||||
|
while (scope) {
|
||||||
|
scopep = scope;
|
||||||
|
scope = scope->next;
|
||||||
|
free(scopep->px_id);
|
||||||
|
free(scopep);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(uri_auth);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Local variables:
|
* Local variables:
|
||||||
* c-indent-level: 8
|
* c-indent-level: 8
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user