Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect "FATAL: Trying to access upstream ID -1" warning in the logs #1061

Merged
merged 1 commit into from
Feb 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/database/query-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,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 @@ -1933,7 +1933,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 @@ -994,6 +994,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