mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-11 03:31:36 +00:00
REORG: server: add a free server function
Create a new server function named free_server. It can be used to deallocate a server and its member.
This commit is contained in:
parent
18487fb532
commit
828adf0121
@ -59,6 +59,7 @@ int srv_set_addr_via_libc(struct server *srv, int *err_code);
|
||||
int srv_init_addr(void);
|
||||
struct server *cli_find_server(struct appctx *appctx, char *arg);
|
||||
struct server *new_server(struct proxy *proxy);
|
||||
void free_server(struct server *srv);
|
||||
|
||||
/* functions related to server name resolution */
|
||||
int srv_prepare_for_resolution(struct server *srv, const char *hostname);
|
||||
|
@ -2660,31 +2660,10 @@ void deinit(void)
|
||||
while (s) {
|
||||
s_next = s->next;
|
||||
|
||||
|
||||
task_destroy(s->warmup);
|
||||
|
||||
free(s->id);
|
||||
free(s->cookie);
|
||||
free(s->hostname);
|
||||
free(s->hostname_dn);
|
||||
free((char*)s->conf.file);
|
||||
free(s->per_thr);
|
||||
free(s->curr_idle_thr);
|
||||
free(s->resolvers_id);
|
||||
free(s->addr_node.key);
|
||||
|
||||
if (s->use_ssl == 1 || s->check.use_ssl == 1 || (s->proxy->options & PR_O_TCPCHK_SSL)) {
|
||||
if (xprt_get(XPRT_SSL) && xprt_get(XPRT_SSL)->destroy_srv)
|
||||
xprt_get(XPRT_SSL)->destroy_srv(s);
|
||||
}
|
||||
HA_SPIN_DESTROY(&s->lock);
|
||||
|
||||
list_for_each_entry(srvdf, &server_deinit_list, list)
|
||||
srvdf->fct(s);
|
||||
|
||||
EXTRA_COUNTERS_FREE(s->extra_counters);
|
||||
LIST_DEL(&s->global_list);
|
||||
free(s);
|
||||
free_server(s);
|
||||
s = s_next;
|
||||
}/* end while(s) */
|
||||
|
||||
|
30
src/server.c
30
src/server.c
@ -1840,6 +1840,36 @@ struct server *new_server(struct proxy *proxy)
|
||||
return srv;
|
||||
}
|
||||
|
||||
/* Deallocate a server <srv> and its member. <srv> must be allocated.
|
||||
*/
|
||||
void free_server(struct server *srv)
|
||||
{
|
||||
task_destroy(srv->warmup);
|
||||
|
||||
free(srv->id);
|
||||
free(srv->cookie);
|
||||
free(srv->hostname);
|
||||
free(srv->hostname_dn);
|
||||
free((char*)srv->conf.file);
|
||||
free(srv->per_thr);
|
||||
free(srv->curr_idle_thr);
|
||||
free(srv->resolvers_id);
|
||||
free(srv->addr_node.key);
|
||||
|
||||
if (srv->use_ssl == 1 || srv->check.use_ssl == 1 || (srv->proxy->options & PR_O_TCPCHK_SSL)) {
|
||||
if (xprt_get(XPRT_SSL) && xprt_get(XPRT_SSL)->destroy_srv)
|
||||
xprt_get(XPRT_SSL)->destroy_srv(srv);
|
||||
}
|
||||
HA_SPIN_DESTROY(&srv->lock);
|
||||
|
||||
LIST_DEL(&srv->global_list);
|
||||
|
||||
EXTRA_COUNTERS_FREE(srv->extra_counters);
|
||||
|
||||
free(srv);
|
||||
srv = NULL;
|
||||
}
|
||||
|
||||
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
|
||||
static int server_sni_expr_init(const char *file, int linenum, char **args, int cur_arg,
|
||||
struct server *srv, struct proxy *proxy)
|
||||
|
Loading…
Reference in New Issue
Block a user