make sure we initilize the database mutex at the beginning of db_init() to ensure we always have the lock available.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2019-08-04 18:50:38 +02:00
parent 0a78b27698
commit 894598e89d
+8 -7
View File
@@ -221,6 +221,14 @@ void db_init(void)
return;
}
// Initialize database lock mutex
if (pthread_mutex_init(&dblock, NULL) != 0)
{
logg("FATAL: FTL_db mutex init failed\n");
// Return failure
exit(EXIT_FAILURE);
}
// Initialize SQLite3 logging callback
// This ensures SQLite3 errors and warnings are logged to pihole-FTL.log
// We use this to possibly catch even more errors in places we do not
@@ -322,13 +330,6 @@ void db_init(void)
// we already closed the database when we returned earlier
sqlite3_close(FTL_db);
if (pthread_mutex_init(&dblock, NULL) != 0)
{
logg("FATAL: FTL_db mutex init failed\n");
// Return failure
exit(EXIT_FAILURE);
}
logg("Database successfully initialized");
}