projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #2688 from dstathis/master
[collectd.git]
/
src
/
mysql.c
diff --git
a/src/mysql.c
b/src/mysql.c
index
7fe6d76
..
448f7cb
100644
(file)
--- a/
src/mysql.c
+++ b/
src/mysql.c
@@
-270,12
+270,16
@@
static MYSQL *getconnection(mysql_database_t *db) {
}
db->is_connected = 0;
}
db->is_connected = 0;
+ /* Close the old connection before initializing a new one. */
+ if (db->con != NULL) {
+ mysql_close(db->con);
+ db->con = NULL;
+ }
+
+ db->con = mysql_init(NULL);
if (db->con == NULL) {
if (db->con == NULL) {
- db->con = mysql_init(NULL);
- if (db->con == NULL) {
- ERROR("mysql plugin: mysql_init failed: %s", mysql_error(db->con));
- return NULL;
- }
+ ERROR("mysql plugin: mysql_init failed: %s", mysql_error(db->con));
+ return NULL;
}
/* Configure TCP connect timeout (default: 0) */
}
/* Configure TCP connect timeout (default: 0) */