Fix timing out DNS lookups that were already resolved

This could happen in the case of making repeated lookup requests
for the same thing within a short period of time: cleaning up an
old request that already got resolved would mistakenly see a new,
yet-to-be-resolved request with identical host/addr and mistakenly
assume it's in need of being timed out.
This commit is contained in:
Jon Siwek 2019-05-01 23:08:52 -07:00
parent fd11c63efe
commit 46799f7540
2 changed files with 15 additions and 8 deletions

View file

@ -1407,12 +1407,15 @@ void DNS_Mgr::DoProcess()
if ( req->time + DNS_TIMEOUT > current_time() )
break;
if ( req->IsAddrReq() )
CheckAsyncAddrRequest(req->host, true);
else if ( req->is_txt )
CheckAsyncTextRequest(req->name.c_str(), true);
else
CheckAsyncHostRequest(req->name.c_str(), true);
if ( ! req->processed )
{
if ( req->IsAddrReq() )
CheckAsyncAddrRequest(req->host, true);
else if ( req->is_txt )
CheckAsyncTextRequest(req->name.c_str(), true);
else
CheckAsyncHostRequest(req->name.c_str(), true);
}
asyncs_timeouts.pop();
delete req;

View file

@ -172,12 +172,13 @@ protected:
struct AsyncRequest {
double time;
bool is_txt;
bool processed;
IPAddr host;
string name;
bool is_txt;
CallbackList callbacks;
AsyncRequest() : time(0.0), is_txt(false) { }
AsyncRequest() : time(0.0), is_txt(false), processed(false) { }
bool IsAddrReq() const { return name.length() == 0; }
@ -190,6 +191,7 @@ protected:
delete *i;
}
callbacks.clear();
processed = true;
}
void Resolved(TableVal* addrs)
@ -201,6 +203,7 @@ protected:
delete *i;
}
callbacks.clear();
processed = true;
}
void Timeout()
@ -212,6 +215,7 @@ protected:
delete *i;
}
callbacks.clear();
processed = true;
}
};