mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Add a second in-memory database to ensure non-blocking operation at all times
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -60,17 +60,28 @@ void *DB_thread(void *val)
|
||||
|
||||
// Save timestamp as we do not want to store immediately
|
||||
// to the database
|
||||
time_t lastDBsave = time(NULL) - time(NULL)%config.DBinterval;
|
||||
time_t before = time(NULL);
|
||||
time_t lastDBsave = before - before%config.DBinterval;
|
||||
|
||||
while(!killed)
|
||||
{
|
||||
if(FTL_DB_avail())
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
|
||||
// Move queries from non-blocking newdb into the larger memdb
|
||||
// Do this once per second
|
||||
if(now > before)
|
||||
{
|
||||
mv_newdb_memdb();
|
||||
before = now;
|
||||
}
|
||||
|
||||
// Store queries in on-disk database
|
||||
if(now - lastDBsave >= config.DBinterval)
|
||||
{
|
||||
// Update lastDBsave timer
|
||||
lastDBsave = time(NULL) - time(NULL)%config.DBinterval;
|
||||
lastDBsave = now - now%config.DBinterval;
|
||||
|
||||
// Save data to database (if enabled)
|
||||
if(config.DBexport)
|
||||
|
||||
Reference in New Issue
Block a user