From c73d60a8754d49fe6996e626fa5486359b4239e8 Mon Sep 17 00:00:00 2001 From: Mr-DaveDev Date: Sun, 12 Apr 2020 18:29:23 -0600 Subject: [PATCH] Adjust Mariadb init and deinit (#1133) Closes #1123 --- src/motion.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/motion.c b/src/motion.c index c35a6b147..71050f592 100644 --- a/src/motion.c +++ b/src/motion.c @@ -1039,10 +1039,7 @@ static int dbse_init_mysql(struct context *cnt){ #if defined(HAVE_MYSQL) || defined(HAVE_MARIADB) int dbport; if ((!strcmp(cnt->conf.database_type, "mysql")) && (cnt->conf.database_dbname)) { - // close database to be sure that we are not leaking - mysql_close(cnt->database); cnt->database_event_id = 0; - cnt->database = mymalloc(sizeof(MYSQL)); mysql_init(cnt->database); if ((cnt->conf.database_port < 0) || (cnt->conf.database_port > 65535)){ @@ -1167,6 +1164,7 @@ static void dbse_deinit(struct context *cnt){ if (cnt->conf.database_type) { #if defined(HAVE_MYSQL) || defined(HAVE_MARIADB) if ( (!strcmp(cnt->conf.database_type, "mysql")) && (cnt->conf.database_dbname)) { + mysql_thread_end(); mysql_close(cnt->database); cnt->database_event_id = 0; }