mirror of
https://github.com/haproxy/haproxy.git
synced 2026-02-20 00:10:41 -05:00
CLEANUP: lb-chash: free lb_nodes from chash's deinit(), not global
There's an ambuity on the ownership of lb_nodes in chash, it's allocated by chash but freed by the server code in srv_free_params() from srv_drop() upon deinit. Let's move this free() call to a chash-specific function which will own the responsibility for doing this instead. Note that the .server_deinit() callback is properly called both on proxy being taken down and on server deletion.
This commit is contained in:
parent
91a5b67b25
commit
62239539bf
2 changed files with 7 additions and 1 deletions
|
|
@ -552,6 +552,12 @@ struct server *chash_get_next_server(struct proxy *p, struct server *srvtoavoid)
|
|||
return srv;
|
||||
}
|
||||
|
||||
/* Releases the allocated lb_nodes for this server */
|
||||
void chash_server_deinit(struct server *srv)
|
||||
{
|
||||
ha_free(&srv->lb_nodes);
|
||||
}
|
||||
|
||||
/* This function is responsible for building the active and backup trees for
|
||||
* consistent hashing. The servers receive an array of initialized nodes
|
||||
* with their assigned keys. It also sets p->lbprm.wdiv to the eweight to
|
||||
|
|
@ -567,6 +573,7 @@ int chash_init_server_tree(struct proxy *p)
|
|||
p->lbprm.set_server_status_up = chash_set_server_status_up;
|
||||
p->lbprm.set_server_status_down = chash_set_server_status_down;
|
||||
p->lbprm.update_server_eweight = chash_update_server_weight;
|
||||
p->lbprm.server_deinit = chash_server_deinit;
|
||||
p->lbprm.server_take_conn = NULL;
|
||||
p->lbprm.server_drop_conn = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -3184,7 +3184,6 @@ void srv_free_params(struct server *srv)
|
|||
free(srv->cc_algo);
|
||||
free(srv->tcp_md5sig);
|
||||
free(srv->addr_key);
|
||||
free(srv->lb_nodes);
|
||||
counters_be_shared_drop(&srv->counters.shared);
|
||||
if (srv->log_target) {
|
||||
deinit_log_target(srv->log_target);
|
||||
|
|
|
|||
Loading…
Reference in a new issue