Fixed a memory leak in all the monitors when a failed mysql_ping to the database caused a reinitialization of MYSQL* connection.

This commit is contained in:
Markus Makela 2015-05-07 11:42:14 +03:00
parent daf5b80a6f
commit fdd5a10478
4 changed files with 8 additions and 2 deletions

View File

@ -377,6 +377,8 @@ char *server_string;
int read_timeout = handle->read_timeout;
int write_timeout = handle->write_timeout;
if(database->con)
mysql_close(database->con);
database->con = mysql_init(NULL);
rc = mysql_options(database->con, MYSQL_OPT_CONNECT_TIMEOUT, (void *)&connect_timeout);

View File

@ -360,7 +360,8 @@ char *server_string;
char *dpwd = decryptPassword(passwd);
int rc;
int read_timeout = 1;
if(database->con)
mysql_close(database->con);
database->con = mysql_init(NULL);
rc = mysql_options(database->con, MYSQL_OPT_READ_TIMEOUT, (void *)&read_timeout);

View File

@ -401,7 +401,8 @@ char *server_string;
int connect_timeout = handle->connect_timeout;
int read_timeout = handle->read_timeout;
int write_timeout = handle->write_timeout;
if(database->con)
mysql_close(database->con);
database->con = mysql_init(NULL);
rc = mysql_options(database->con, MYSQL_OPT_CONNECT_TIMEOUT, (void *)&connect_timeout);

View File

@ -338,6 +338,8 @@ char *server_string;
int read_timeout = handle->read_timeout;
int write_timeout = handle->write_timeout;
if(database->con)
mysql_close(database->con);
database->con = mysql_init(NULL);
rc = mysql_options(database->con, MYSQL_OPT_CONNECT_TIMEOUT, (void *)&connect_timeout);