You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
enhanced mysql_close() and other related parts to prevent memory leaks when terminating an initiated but unestablished connection
This commit is contained in:
@@ -1737,7 +1737,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;
|
||||
@@ -2343,6 +2354,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)
|
||||
|
Reference in New Issue
Block a user