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:
DL6ER
2017-12-31 00:54:21 +01:00
parent d0968c68aa
commit 90cf01bbc5
+9 -4
View File
@@ -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