BUG/MINOR: server: fix dynamic server leak with check on failed init
If a dynamic server is added with check or agent-check, its refcount is incremented after server keyword parsing. However, if add server fails at a later stage, refcount is only decremented once, which prevented the server to be fully released. This causes a leak with a server which is detached from most of the lists but still exits in the system. This bug is considered minor as only a few conditions may cause a failure in add server after check/agent-check initialization. This is the case if there is a naming collision or the dynamic ID cannot be generated. To fix this, simply decrement server refcount on add server error path if either check and/or agent-check are flagged as activated. This bug is related to github issue #2733. Thanks to Chris Staite who first found the leak. This must be backported up to 2.6.
This commit is contained in:
parent
ddb829bb51
commit
116178563c
|
@ -5975,10 +5975,14 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct
|
|||
if (srv->track)
|
||||
release_server_track(srv);
|
||||
|
||||
if (srv->check.state & CHK_ST_CONFIGURED)
|
||||
if (srv->check.state & CHK_ST_CONFIGURED) {
|
||||
free_check(&srv->check);
|
||||
if (srv->agent.state & CHK_ST_CONFIGURED)
|
||||
srv_drop(srv);
|
||||
}
|
||||
if (srv->agent.state & CHK_ST_CONFIGURED) {
|
||||
free_check(&srv->agent);
|
||||
srv_drop(srv);
|
||||
}
|
||||
|
||||
/* remove the server from the proxy linked list */
|
||||
_srv_detach(srv);
|
||||
|
|
Loading…
Reference in New Issue