Patchwork [Ulogd,2/4] mysql: add sanity checking

login
register
mail settings
Submitter Eric Leblond
Date March 18, 2013, 12:01 a.m.
Message ID <1363564884-5957-3-git-send-email-eric@regit.org>
Download mbox | patch
Permalink /patch/228339/
State Not Applicable
Headers show

Comments

Eric Leblond - March 18, 2013, 12:01 a.m.
Nullify mysql handler at deinit.

Signed-off-by: Eric Leblond <eric@regit.org>
---
 output/mysql/ulogd_output_MYSQL.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch

diff --git a/output/mysql/ulogd_output_MYSQL.c b/output/mysql/ulogd_output_MYSQL.c
index 72c080e..37c30cc 100644
--- a/output/mysql/ulogd_output_MYSQL.c
+++ b/output/mysql/ulogd_output_MYSQL.c
@@ -162,7 +162,9 @@  static int get_columns_mysql(struct ulogd_pluginstance *upi)
 static int close_db_mysql(struct ulogd_pluginstance *upi)
 {
 	struct mysql_instance *mi = (struct mysql_instance *) upi->private;
-	mysql_close(mi->dbh);
+	if (mi->dbh)
+		mysql_close(mi->dbh);
+	pi->dbh = NULL;
 	return 0;
 }