1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-08 14:02:17 +03:00

Merge pull request #199 from hyung-hwan/3.3

enhanced mysql_close_slow_part() and other related parts to prevent memory leaks in the non-blocking mode
This commit is contained in:
Georg Richter
2022-07-25 09:22:04 +02:00
committed by GitHub
3 changed files with 56 additions and 4 deletions

View File

@@ -1738,7 +1738,18 @@ restart:
}
if (ma_net_init(net, pvio))
{
ma_pvio_close(pvio);
goto error;
}
if (mysql->options.extension && mysql->options.extension->async_context && mysql->options.extension->async_context->pvio)
{
/* pvio delegated to mysql->net.pvio by ma_net_init().
* invalidate the pvio pointer in the async context */
mysql->options.extension->async_context->pvio = NULL;
}
if (mysql->options.max_allowed_packet)
net->max_packet_size= mysql->options.max_allowed_packet;
@@ -2349,6 +2360,20 @@ void mysql_close_slow_part(MYSQL *mysql)
ma_simple_command(mysql, COM_QUIT,NullS,0,1,0);
end_server(mysql);
}
/* there is an ongoing async operation */
else if (mysql->options.extension && mysql->options.extension->async_context)
{
if (mysql->options.extension->async_context->pending_gai_res)
{
freeaddrinfo(mysql->options.extension->async_context->pending_gai_res);
mysql->options.extension->async_context->pending_gai_res = 0;
}
if (mysql->options.extension->async_context->pvio)
{
ma_pvio_close(mysql->options.extension->async_context->pvio);
mysql->options.extension->async_context->pvio = 0;
}
}
}
static void ma_clear_session_state(MYSQL *mysql)