Skip to content

Commit

Permalink
Compare age of query against current time to decide if we should give…
Browse files Browse the repository at this point in the history
… a query more time to get completed

Signed-off-by: DL6ER <dl6er@dl6er.de>
  • Loading branch information
DL6ER committed Dec 28, 2017
1 parent dbc9457 commit d669a65
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion database.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,21 @@ void save_to_DB(void)
return;
}

int currenttimestamp = time(NULL);
for(i = lastdbindex; i < counters.queries; i++)
{
validate_access("queries", i, true, __LINE__, __FUNCTION__, __FILE__);
if(queries[i].timestamp <= lasttimestamp || queries[i].db || !queries[i].complete)
if(queries[i].timestamp <= lasttimestamp || queries[i].db)
// Already in database or not yet complete
continue;

if(!queries[i].complete && queries[i].timestamp > currenttimestamp-2)
{
// Break if a brand new query (age < 2 seconds) is not yet completed
// giving it a chance to be stored next time
break;
}

// Memory checks
validate_access("queries", i, true, __LINE__, __FUNCTION__, __FILE__);
validate_access("domains", queries[i].domainID, true, __LINE__, __FUNCTION__, __FILE__);
Expand Down

0 comments on commit d669a65

Please sign in to comment.