Unlock shared memory during database committing

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2024-04-25 20:33:34 +02:00
parent 1c2257bed6
commit 95fb8fe1b1
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD
1 changed files with 13 additions and 0 deletions

View File

@ -489,6 +489,13 @@ int DB_save_queries(sqlite3 *db)
db_update_counters(db, total, blocked);
}
// Temporarily unlock shared memory as committing to the database may
// take a long time, even more on systems with slow disks or heavy I/O
// load. We don't want the shared memory lock to be needlessly helt
// during this time to avoid blocking DNS resolution when there is no
// need to
unlock_shm();
// Finish prepared statement
if((rc = dbquery(db,"END TRANSACTION")) != SQLITE_OK)
{
@ -503,6 +510,9 @@ int DB_save_queries(sqlite3 *db)
if(db_opened) dbclose(&db);
// Re-lock shared memory before returning
lock_shm();
return DB_FAILED;
}
@ -519,6 +529,9 @@ int DB_save_queries(sqlite3 *db)
if(db_opened) dbclose(&db);
// Re-lock shared memory before returning
lock_shm();
return saved;
}