Skip to content

Commit

Permalink
Garbage collect query types (speed enhancements, PTR, SRV)
Browse files Browse the repository at this point in the history
  • Loading branch information
DL6ER committed Mar 13, 2017
1 parent a859abc commit 40375ab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
15 changes: 15 additions & 0 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ void *GC_thread(void *val)
default: /* That cannot happen */ break;
}

switch(queries[i].type)
{
case 1: counters.IPv4--; break;
case 2: counters.IPv6--; break;
default: logg("ERROR in GC"); break;
}

// Remove forwarded data from overTime and total forwarded count
int j;
for(j = 0; j < overTime[queries[i].timeidx].forwardnum; j++)
{
forwarded[j].count -= overTime[queries[i].timeidx].forwarddata[j];
overTime[queries[i].timeidx].forwarddata[j] = 0;
}

// Mark this query as garbage collected
queries[i].valid = false;

Expand Down
8 changes: 0 additions & 8 deletions parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,14 +504,6 @@ void process_pihole_log(int file)
logg("dnsmasq process restarted");
read_gravity_files();
}
else if(strstr(readbuffer,"query[PTR]"))
{
counters.PTR++;
}
else if(strstr(readbuffer,"query[SRV]"))
{
counters.SRV++;
}

// Save file pointer position, because we might have to repeat
// reading the next line if dnsmasq hasn't finished writing it
Expand Down
2 changes: 1 addition & 1 deletion request.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void process_request(char *client_message, int *sock)
else if(command(client_message, ">querytypes"))
{
processed = true;
sprintf(server_message,"A (IPv4): %i\nAAAA (IPv6): %i\nPTR: %i\nSRV: %i\n",counters.IPv4,counters.IPv6,counters.PTR,counters.SRV);
sprintf(server_message,"A (IPv4): %i\nAAAA (IPv6): %i\n",counters.IPv4,counters.IPv6);
swrite(server_message, *sock);
if(debugclients)
logg_int("Sent query type data to client, ID: ", *sock);
Expand Down

0 comments on commit 40375ab

Please sign in to comment.