Skip to content

Commit

Permalink
Skip the analysis of too old queries in the logs altogether. By this,…
Browse files Browse the repository at this point in the history
… we can skip the initial GC run, since there will be nothing to be collected
  • Loading branch information
DL6ER committed Apr 20, 2017
1 parent 18202cb commit e4628eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
10 changes: 0 additions & 10 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,6 @@ int main (int argc, char* argv[]) {
killed = 1;
}

if(config.rolling_24h)
{
pthread_t GCthread;
if(pthread_create( &GCthread, &attr, GC_thread, NULL ) != 0)
{
logg("Unable to start initial GC thread. Exiting...");
killed = 1;
}
}

while(!killed)
{
sleepms(100);
Expand Down
6 changes: 6 additions & 0 deletions parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ void process_pihole_log(int file)
int querytimestamp, overTimetimestamp;
extracttimestamp(readbuffer, &querytimestamp, &overTimetimestamp);

// Get minimum time stamp to analyze
int differencetofullhour = time(NULL) % GCinterval;
int mintime = (time(NULL) - GCdelay - differencetofullhour) - MAXLOGAGE;
// Skip parsing of log entries that are too old altogether if 24h window is requested
if(config.rolling_24h && querytimestamp < mintime) continue;

// Ensure we have enough space in the queries struct
memory_check(QUERIES);
int queryID = counters.queries;
Expand Down

0 comments on commit e4628eb

Please sign in to comment.