MXS-2183: Fix memory leaks
Under heavy load some of the basic network operations could fail which led to some of the allocated memory to leak. Also the backend protocol never freed the current protocol command if it was not completed. This would happen if a user executed a session command as the first command but backend authentication would fail.
This commit is contained in:
parent
24d1876ed4
commit
6451b1f21a
@ -1021,8 +1021,6 @@ int open_network_socket(enum mxs_socket_type type, struct sockaddr_storage *addr
|
||||
memcpy(addr, ai->ai_addr, ai->ai_addrlen);
|
||||
set_port(addr, port);
|
||||
|
||||
freeaddrinfo(ai);
|
||||
|
||||
if ((type == MXS_SOCKET_NETWORK && !configure_network_socket(so, addr->ss_family)) ||
|
||||
(type == MXS_SOCKET_LISTENER && !configure_listener_socket(so)))
|
||||
{
|
||||
@ -1042,12 +1040,15 @@ int open_network_socket(enum mxs_socket_type type, struct sockaddr_storage *addr
|
||||
|
||||
if (config->local_address)
|
||||
{
|
||||
freeaddrinfo(ai);
|
||||
ai = NULL;
|
||||
|
||||
if ((rc = getaddrinfo(config->local_address, NULL, &hint, &ai)) == 0)
|
||||
{
|
||||
struct sockaddr_storage local_address = {};
|
||||
|
||||
memcpy(&local_address, ai->ai_addr, ai->ai_addrlen);
|
||||
freeaddrinfo(ai);
|
||||
|
||||
|
||||
if (bind(so, (struct sockaddr*)&local_address, sizeof(local_address)) == 0)
|
||||
{
|
||||
@ -1069,6 +1070,8 @@ int open_network_socket(enum mxs_socket_type type, struct sockaddr_storage *addr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
|
||||
return so;
|
||||
|
@ -105,6 +105,16 @@ bool mysql_protocol_done(DCB* dcb)
|
||||
|
||||
gwbuf_free(p->stored_query);
|
||||
|
||||
server_command_t* s = &p->protocol_command;
|
||||
|
||||
while (s->scom_next)
|
||||
{
|
||||
server_command_t tmp = *(s->scom_next);
|
||||
MXS_FREE(s->scom_next);
|
||||
p->protocol_command = tmp;
|
||||
s = &p->protocol_command;
|
||||
}
|
||||
|
||||
p->protocol_state = MYSQL_PROTOCOL_DONE;
|
||||
rval = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user