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:
@ -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;
|
||||
|
Reference in New Issue
Block a user