mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 1544190 - Use a counter to track if there is a pending TRR request, r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D118077
This commit is contained in:
parent
15f7d2932c
commit
cabbcc78fc
@ -41,15 +41,12 @@ void TRRQuery::Cancel(nsresult aStatus) {
|
||||
MutexAutoLock trrlock(mTrrLock);
|
||||
if (mTrrA) {
|
||||
mTrrA->Cancel(aStatus);
|
||||
mTrrA = nullptr;
|
||||
}
|
||||
if (mTrrAAAA) {
|
||||
mTrrAAAA->Cancel(aStatus);
|
||||
mTrrAAAA = nullptr;
|
||||
}
|
||||
if (mTrrByType) {
|
||||
mTrrByType->Cancel(aStatus);
|
||||
mTrrByType = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,10 +133,12 @@ nsresult TRRQuery::DispatchLookup(TRR* pushedTRR, bool aUseODoH) {
|
||||
}
|
||||
} while (sendAgain);
|
||||
|
||||
mTRRRequestCounter = requestsToSend.Length();
|
||||
for (const auto& request : requestsToSend) {
|
||||
if (NS_SUCCEEDED(gTRRService->DispatchTRRRequest(request))) {
|
||||
madeQuery = true;
|
||||
} else {
|
||||
mTRRRequestCounter--;
|
||||
MutexAutoLock trrlock(mTrrLock);
|
||||
if (request == mTrrA) {
|
||||
mTrrA = nullptr;
|
||||
@ -198,8 +197,6 @@ AHostResolver::LookupStatus TRRQuery::CompleteLookup(
|
||||
|
||||
RefPtr<AddrInfo> newRRSet(aNewRRSet);
|
||||
DNSResolverType resolverType = newRRSet->ResolverType();
|
||||
bool pendingARequest = false;
|
||||
bool pendingAAAARequest = false;
|
||||
{
|
||||
MutexAutoLock trrlock(mTrrLock);
|
||||
if (newRRSet->TRRType() == TRRTYPE_A) {
|
||||
@ -215,12 +212,6 @@ AHostResolver::LookupStatus TRRQuery::CompleteLookup(
|
||||
} else {
|
||||
MOZ_ASSERT(0);
|
||||
}
|
||||
if (mTrrA) {
|
||||
pendingARequest = true;
|
||||
}
|
||||
if (mTrrAAAA) {
|
||||
pendingAAAARequest = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(status)) {
|
||||
@ -233,8 +224,14 @@ AHostResolver::LookupStatus TRRQuery::CompleteLookup(
|
||||
}
|
||||
}
|
||||
|
||||
if (pendingARequest ||
|
||||
pendingAAAARequest) { // There are other outstanding requests
|
||||
bool pendingRequest = false;
|
||||
if (mTRRRequestCounter) {
|
||||
mTRRRequestCounter--;
|
||||
pendingRequest = (mTRRRequestCounter != 0);
|
||||
} else {
|
||||
MOZ_DIAGNOSTIC_ASSERT(false, "Request counter is messed up");
|
||||
}
|
||||
if (pendingRequest) { // There are other outstanding requests
|
||||
mFirstTRRresult = status;
|
||||
if (NS_FAILED(status)) {
|
||||
return LOOKUP_OK; // wait for outstanding
|
||||
|
@ -76,6 +76,12 @@ class TRRQuery : public AHostResolver {
|
||||
RefPtr<mozilla::net::TRR> mTrrA;
|
||||
RefPtr<mozilla::net::TRR> mTrrAAAA;
|
||||
RefPtr<mozilla::net::TRR> mTrrByType;
|
||||
// |mTRRRequestCounter| indicates the number of TRR requests that were
|
||||
// dispatched sucessfully. Generally, this counter is increased to 2 after
|
||||
// mTrrA and mTrrAAAA are dispatched, and is decreased by 1 when
|
||||
// CompleteLookup is called. Note that nsHostResolver::CompleteLookup is only
|
||||
// called when this counter equals to 0.
|
||||
Atomic<uint32_t> mTRRRequestCounter{0};
|
||||
|
||||
uint8_t mTRRSuccess = 0; // number of successful TRR responses
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user