From 66ac894c40ad089175aaf6d4922f7250c23b9b3d Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Thu, 11 Aug 2016 17:50:21 +0200 Subject: [PATCH] MDEV-10455: libmariadbclient18 + MySQL-python leaks memory on failed connections Support of CLIENT_REMEMBER_OPTIONS and freeing options added. --- sql-common/client.c | 4 +++- sql/slave.cc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sql-common/client.c b/sql-common/client.c index 9105b72d57c..184d7983a00 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -3644,6 +3644,8 @@ error: /* Free alloced memory */ end_server(mysql); mysql_close_free(mysql); + if (!(client_flag & CLIENT_REMEMBER_OPTIONS)) + mysql_close_free_options(mysql); } DBUG_RETURN(0); } @@ -3714,7 +3716,7 @@ my_bool mysql_reconnect(MYSQL *mysql) } if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd, mysql->db, mysql->port, mysql->unix_socket, - mysql->client_flag)) + mysql->client_flag | CLIENT_REMEMBER_OPTIONS)) { if (ctxt) my_context_install_suspend_resume_hook(ctxt, NULL, NULL); diff --git a/sql/slave.cc b/sql/slave.cc index 5d44fb2b6a8..a309fc5cdc5 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -6061,7 +6061,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, #ifndef DBUG_OFF mi->events_till_disconnect = disconnect_slave_event_count; #endif - ulong client_flag= 0; + ulong client_flag= CLIENT_REMEMBER_OPTIONS; if (opt_slave_compressed_protocol) client_flag=CLIENT_COMPRESS; /* We will use compression */