mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
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:
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user