Verified Commit 1ac984f5 authored by Kershaw Chang's avatar Kershaw Chang Committed by ma1
Browse files

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

parent ae599615
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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 &&
+3 −1
Original line number Diff line number Diff line
@@ -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;
+5 −3
Original line number Diff line number Diff line
@@ -1116,7 +1116,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);
@@ -1900,8 +1901,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));
  }