projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b77e13d
)
Properly cleanup dropped MySQL connections.
author
Dhrupad Bhardwaj
<dhrupad@google.com>
Thu, 1 Mar 2018 23:45:14 +0000
(18:45 -0500)
committer
GitHub
<noreply@github.com>
Thu, 1 Mar 2018 23:45:14 +0000
(18:45 -0500)
src/mysql.c
patch
|
blob
|
history
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) */