mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Have to finalize all statements before sqlite3_close() can succeed. Also print some error message in the future if closeing the database failed.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
+9
-4
@@ -36,7 +36,12 @@ void check_database(int rc)
|
||||
|
||||
void dbclose(void)
|
||||
{
|
||||
sqlite3_close(db);
|
||||
int rc = sqlite3_close(db);
|
||||
// Report any error
|
||||
if( rc )
|
||||
logg("dbclose() - SQL error (%i): %s", rc, sqlite3_errmsg(db));
|
||||
|
||||
// Unlock mutex on the database
|
||||
pthread_mutex_unlock(&dblock);
|
||||
}
|
||||
|
||||
@@ -392,9 +397,9 @@ void save_to_DB(void)
|
||||
}
|
||||
|
||||
// Finish prepared statement
|
||||
ret = dbquery("END TRANSACTION");
|
||||
if(!ret){ dbclose(); return; }
|
||||
sqlite3_finalize(stmt);
|
||||
dbquery("END TRANSACTION");
|
||||
ret = sqlite3_finalize(stmt);
|
||||
if(ret != SQLITE_OK){ dbclose(); return; }
|
||||
|
||||
// Store index for next loop interation round and update last time stamp
|
||||
// in the database only if all queries have been saved successfully
|
||||
|
||||
Reference in New Issue
Block a user