Skip to content

Commit

Permalink
Merge pull request #1061 from pi-hole/fix/retired_dnssec_has_no_upstream
Browse files Browse the repository at this point in the history
Fix incorrect "FATAL: Trying to access upstream ID -1" warning in the logs
  • Loading branch information
DL6ER authored Feb 28, 2021
2 parents e8cb3f6 + d1f764b commit 3fd9b8d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/database/query-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,16 @@ void DB_read_queries(void)
case QUERY_RETRIED: // (fall through)
case QUERY_RETRIED_DNSSEC: // (fall through)
counters->forwarded++;
upstreamsData *upstream = getUpstream(upstreamID, true);
if(upstream != NULL)
// Only update upstream if there is one (there
// won't be one for retried DNSSEC queries)
if(upstreamID > -1)
{
upstream->count++;
upstream->lastQuery = queryTimeStamp;
upstreamsData *upstream = getUpstream(upstreamID, true);
if(upstream != NULL)
{
upstream->count++;
upstream->lastQuery = queryTimeStamp;
}
}
// Update overTime data structure
overTime[timeidx].forwarded++;
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,7 @@ void FTL_forwarding_retried(const struct server *serv, const int oldID, const in
{
if(dnssec)
{
// There is point in retrying the query when
// There is no point in retrying the query when
// we've already got an answer to this query,
// but we're awaiting keys for DNSSEC
// validation. We're retrying the DNSSEC query
Expand Down
4 changes: 4 additions & 0 deletions src/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,10 @@ domainsData* _getDomain(int domainID, bool checkMagic, int line, const char * fu

upstreamsData* _getUpstream(int upstreamID, bool checkMagic, int line, const char * function, const char * file)
{
// This does not exist, we return a NULL pointer
if(upstreamID == -1)
return NULL;

if(check_range(upstreamID, counters->upstreams_MAX, "upstream", line, function, file) &&
check_magic(upstreamID, checkMagic, upstreams[upstreamID].magic, "upstream", line, function, file))
return &upstreams[upstreamID];
Expand Down

0 comments on commit 3fd9b8d

Please sign in to comment.