Bug 1932783 - Make nsHostKey::flags Atomic, a=RyanVM

This commit is contained in:
Kershaw Chang 2024-11-28 13:39:07 +00:00
parent 425cc96639
commit 1db5716074
3 changed files with 17 additions and 4 deletions

View file

@ -39,6 +39,15 @@ nsHostKey::nsHostKey(const nsACString& aHost, const nsACString& aTrrServer,
pb(aPb),
originSuffix(aOriginsuffix) {}
nsHostKey::nsHostKey(const nsHostKey& other)
: host(other.host),
mTrrServer(other.mTrrServer),
type(other.type),
flags(other.flags),
af(other.af),
pb(other.pb),
originSuffix(other.originSuffix) {}
bool nsHostKey::operator==(const nsHostKey& other) const {
return host == other.host && mTrrServer == other.mTrrServer &&
type == other.type &&

View file

@ -79,13 +79,15 @@ struct nsHostKey {
const nsCString host;
const nsCString mTrrServer;
uint16_t type = 0;
nsIDNSService::DNSFlags flags = nsIDNSService::RESOLVE_DEFAULT_FLAGS;
mozilla::Atomic<nsIDNSService::DNSFlags> flags{
nsIDNSService::RESOLVE_DEFAULT_FLAGS};
uint16_t af = 0;
bool pb = false;
const nsCString originSuffix;
explicit nsHostKey(const nsACString& host, const nsACString& aTrrServer,
uint16_t type, nsIDNSService::DNSFlags flags, uint16_t af,
bool pb, const nsACString& originSuffix);
explicit nsHostKey(const nsHostKey& other);
bool operator==(const nsHostKey& other) const;
size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
PLDHashNumber Hash() const;

View file

@ -1185,7 +1185,8 @@ nsresult nsHostResolver::NameLookup(nsHostRecord* rec,
}
LOG(("NameLookup: %s effectiveTRRmode: %d flags: %X", rec->host.get(),
static_cast<nsIRequest::TRRMode>(rec->mEffectiveTRRMode), rec->flags));
static_cast<nsIRequest::TRRMode>(rec->mEffectiveTRRMode),
static_cast<uint32_t>(rec->flags)));
if (rec->flags & nsIDNSService::RESOLVE_DISABLE_TRR) {
rec->RecordReason(TRRSkippedReason::TRR_DISABLED_FLAG);
@ -2032,8 +2033,9 @@ void nsHostResolver::GetDNSCacheEntries(nsTArray<DNSCacheEntries>* args) {
}
info.originAttributesSuffix = recordEntry.GetKey().originSuffix;
info.flags = nsPrintfCString("%u|0x%x|%u|%d|%s", rec->type, rec->flags,
rec->af, rec->pb, rec->mTrrServer.get());
info.flags = nsPrintfCString("%u|0x%x|%u|%d|%s", rec->type,
static_cast<uint32_t>(rec->flags), rec->af,
rec->pb, rec->mTrrServer.get());
args->AppendElement(std::move(info));
}