mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1700076 - Fix modernize-use-default-member-init clang-tidy warnings in netwerk/dns/ r=necko-reviewers,dragana
This patch consists of the changes generated by running `./mach static-analysis check --fix` on `netwerk/dns` after adding the `modernize-use-default-member-init` clang-tidy lint. Some additional changes were made by hand to ensure consistent results. This patch ensures that all member variables are initialized in the header, so when adding or changing constructors we don't miss one resulting in uninitialized memory. Differential Revision: https://phabricator.services.mozilla.com/D109339
This commit is contained in:
parent
b3f920ee42
commit
ca325c9add
@ -53,8 +53,7 @@ already_AddRefed<ChildDNSService> ChildDNSService::GetSingleton() {
|
||||
|
||||
NS_IMPL_ISUPPORTS(ChildDNSService, nsIDNSService, nsPIDNSService, nsIObserver)
|
||||
|
||||
ChildDNSService::ChildDNSService()
|
||||
: mPendingRequestsLock("DNSPendingRequestsLock") {
|
||||
ChildDNSService::ChildDNSService() {
|
||||
MOZ_ASSERT_IF(nsIOService::UseSocketProcess(),
|
||||
XRE_IsContentProcess() || XRE_IsParentProcess());
|
||||
MOZ_ASSERT_IF(!nsIOService::UseSocketProcess(),
|
||||
|
@ -60,7 +60,7 @@ class ChildDNSService final : public nsPIDNSService, public nsIObserver {
|
||||
// We need to remember pending dns requests to be able to cancel them.
|
||||
nsClassHashtable<nsCStringHashKey, nsTArray<RefPtr<DNSRequestSender>>>
|
||||
mPendingRequests;
|
||||
Mutex mPendingRequestsLock;
|
||||
Mutex mPendingRequestsLock{"DNSPendingRequestsLock"};
|
||||
RefPtr<TRRServiceParent> mTRRServiceParent;
|
||||
};
|
||||
|
||||
|
@ -209,13 +209,10 @@ bool NetAddr::IsIPAddrV4Mapped() const {
|
||||
|
||||
static bool isLocalIPv4(uint32_t networkEndianIP) {
|
||||
uint32_t addr32 = ntohl(networkEndianIP);
|
||||
if (addr32 >> 24 == 0x0A || // 10/8 prefix (RFC 1918).
|
||||
addr32 >> 20 == 0xAC1 || // 172.16/12 prefix (RFC 1918).
|
||||
addr32 >> 16 == 0xC0A8 || // 192.168/16 prefix (RFC 1918).
|
||||
addr32 >> 16 == 0xA9FE) { // 169.254/16 prefix (Link Local).
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return addr32 >> 24 == 0x0A || // 10/8 prefix (RFC 1918).
|
||||
addr32 >> 20 == 0xAC1 || // 172.16/12 prefix (RFC 1918).
|
||||
addr32 >> 16 == 0xC0A8 || // 192.168/16 prefix (RFC 1918).
|
||||
addr32 >> 16 == 0xA9FE; // 169.254/16 prefix (Link Local).
|
||||
}
|
||||
|
||||
bool NetAddr::IsIPAddrLocal() const {
|
||||
|
@ -178,7 +178,7 @@ enum ObliviousDoHMessageType : uint8_t {
|
||||
};
|
||||
|
||||
struct ObliviousDoHMessage {
|
||||
ObliviousDoHMessageType mType;
|
||||
ObliviousDoHMessageType mType{ODOH_QUERY};
|
||||
nsTArray<uint8_t> mKeyId;
|
||||
nsTArray<uint8_t> mEncryptedMessage;
|
||||
};
|
||||
|
@ -1393,9 +1393,8 @@ static SECStatus HKDFExtract(SECItem* aSalt, PK11SymKey* aIkm,
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
static SECStatus HKDFExpand(PK11SymKey* aPrk, const SECItem* aInfo,
|
||||
unsigned int aLen, bool aKey,
|
||||
UniquePK11SymKey& aOutKey) {
|
||||
static SECStatus HKDFExpand(PK11SymKey* aPrk, const SECItem* aInfo, int aLen,
|
||||
bool aKey, UniquePK11SymKey& aOutKey) {
|
||||
CK_HKDF_PARAMS params = {0};
|
||||
SECItem paramsItem = {siBuffer, (unsigned char*)¶ms, sizeof(params)};
|
||||
|
||||
@ -1449,8 +1448,8 @@ bool ODoHDNSPacket::DecryptDNSResponse() {
|
||||
const SECItem kODoHSecretInfoItem = {
|
||||
siBuffer, (unsigned char*)kODoHSecret,
|
||||
static_cast<unsigned int>(strlen(kODoHSecret))};
|
||||
const unsigned int kAes128GcmKeyLen = 16;
|
||||
const unsigned int kAes128GcmNonceLen = 12;
|
||||
const int kAes128GcmKeyLen = 16;
|
||||
const int kAes128GcmNonceLen = 12;
|
||||
PK11SymKey* tmp = nullptr;
|
||||
SECStatus rv =
|
||||
PK11_HPKE_ExportSecret(mContext, &kODoHSecretInfoItem, 32, &tmp);
|
||||
|
@ -85,12 +85,12 @@ class DNSRequestSender final : public DNSRequestBase, public nsICancelable {
|
||||
nsCOMPtr<nsIDNSListener> mListener;
|
||||
nsCOMPtr<nsIEventTarget> mTarget;
|
||||
nsCOMPtr<nsIDNSRecord> mResultRecord;
|
||||
nsresult mResultStatus;
|
||||
nsresult mResultStatus = NS_OK;
|
||||
nsCString mHost;
|
||||
nsCString mTrrServer;
|
||||
uint16_t mType;
|
||||
uint16_t mType = 0;
|
||||
const OriginAttributes mOriginAttributes;
|
||||
uint16_t mFlags;
|
||||
uint16_t mFlags = 0;
|
||||
};
|
||||
|
||||
// DNSRequestHandler handles the dns request and sends the result back via IPC.
|
||||
@ -100,7 +100,7 @@ class DNSRequestHandler final : public DNSRequestBase, public nsIDNSListener {
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIDNSLISTENER
|
||||
|
||||
DNSRequestHandler();
|
||||
DNSRequestHandler() = default;
|
||||
|
||||
void DoAsyncResolve(const nsACString& hostname, const nsACString& trrServer,
|
||||
uint16_t type, const OriginAttributes& originAttributes,
|
||||
@ -120,7 +120,7 @@ class DNSRequestHandler final : public DNSRequestBase, public nsIDNSListener {
|
||||
private:
|
||||
virtual ~DNSRequestHandler() = default;
|
||||
|
||||
uint32_t mFlags;
|
||||
uint32_t mFlags = 0;
|
||||
};
|
||||
|
||||
// Provides some common methods for DNSRequestChild and DNSRequestParent.
|
||||
|
@ -49,18 +49,18 @@ class ChildDNSRecord : public nsIDNSAddrRecord {
|
||||
|
||||
nsCString mCanonicalName;
|
||||
nsTArray<NetAddr> mAddresses;
|
||||
uint32_t mCurrent; // addr iterator
|
||||
uint16_t mFlags;
|
||||
double mTrrFetchDuration;
|
||||
double mTrrFetchDurationNetworkOnly;
|
||||
bool mIsTRR;
|
||||
uint32_t mEffectiveTRRMode;
|
||||
uint32_t mCurrent = 0; // addr iterator
|
||||
uint16_t mFlags = 0;
|
||||
double mTrrFetchDuration = 0;
|
||||
double mTrrFetchDurationNetworkOnly = 0;
|
||||
bool mIsTRR = false;
|
||||
uint32_t mEffectiveTRRMode = 0;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(ChildDNSRecord, nsIDNSRecord, nsIDNSAddrRecord)
|
||||
|
||||
ChildDNSRecord::ChildDNSRecord(const DNSRecord& reply, uint16_t flags)
|
||||
: mCurrent(0), mFlags(flags) {
|
||||
: mFlags(flags) {
|
||||
mCanonicalName = reply.canonicalName();
|
||||
mTrrFetchDuration = reply.trrFetchDuration();
|
||||
mTrrFetchDurationNetworkOnly = reply.trrFetchDurationNetworkOnly();
|
||||
@ -208,7 +208,7 @@ NS_IMPL_ISUPPORTS(ChildDNSByTypeRecord, nsIDNSByTypeRecord, nsIDNSRecord,
|
||||
|
||||
ChildDNSByTypeRecord::ChildDNSByTypeRecord(const TypeRecordResultType& reply,
|
||||
const nsACString& aHost)
|
||||
: DNSHTTPSSVCRecordBase(aHost), mAllRecordsExcluded(false) {
|
||||
: DNSHTTPSSVCRecordBase(aHost) {
|
||||
mResults = reply;
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,6 @@ using namespace mozilla::ipc;
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
DNSRequestHandler::DNSRequestHandler() : mFlags(0) {}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// DNSRequestHandler::nsISupports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -66,13 +66,13 @@ class NativeDNSResolverOverride : public nsINativeDNSResolverOverride {
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSINATIVEDNSRESOLVEROVERRIDE
|
||||
public:
|
||||
NativeDNSResolverOverride() : mLock("NativeDNSResolverOverride") {}
|
||||
NativeDNSResolverOverride() = default;
|
||||
|
||||
static already_AddRefed<nsINativeDNSResolverOverride> GetSingleton();
|
||||
|
||||
private:
|
||||
virtual ~NativeDNSResolverOverride() = default;
|
||||
mozilla::RWLock mLock;
|
||||
mozilla::RWLock mLock{"NativeDNSResolverOverride"};
|
||||
|
||||
nsTHashMap<nsCStringHashKey, nsTArray<PRNetAddr>> mOverrides;
|
||||
nsTHashMap<nsCStringHashKey, nsCString> mCnames;
|
||||
|
@ -116,10 +116,10 @@ class TRR : public Runnable,
|
||||
void StoreIPHintAsDNSRecord(const struct SVCB& aSVCBRecord);
|
||||
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
enum TrrType mType;
|
||||
enum TrrType mType { TRRTYPE_A };
|
||||
UniquePtr<DNSPacket> mPacket;
|
||||
bool mFailed = false;
|
||||
bool mPB;
|
||||
bool mPB = false;
|
||||
DOHresp mDNS;
|
||||
nsresult mChannelStatus = NS_OK;
|
||||
|
||||
|
@ -71,8 +71,7 @@ class nsDNSRecord : public nsIDNSAddrRecord {
|
||||
NS_DECL_NSIDNSRECORD
|
||||
NS_DECL_NSIDNSADDRRECORD
|
||||
|
||||
explicit nsDNSRecord(nsHostRecord* hostRecord)
|
||||
: mIterGenCnt(-1), mDone(false) {
|
||||
explicit nsDNSRecord(nsHostRecord* hostRecord) {
|
||||
mHostRecord = do_QueryObject(hostRecord);
|
||||
}
|
||||
|
||||
@ -95,10 +94,10 @@ class nsDNSRecord : public nsIDNSAddrRecord {
|
||||
return &*mIter;
|
||||
}
|
||||
|
||||
int mIterGenCnt; // the generation count of
|
||||
// mHostRecord->addr_info when we
|
||||
// start iterating
|
||||
bool mDone;
|
||||
int mIterGenCnt = -1; // the generation count of
|
||||
// mHostRecord->addr_info when we
|
||||
// start iterating
|
||||
bool mDone = false;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsDNSRecord, nsIDNSRecord, nsIDNSAddrRecord)
|
||||
@ -465,12 +464,12 @@ class nsDNSAsyncRequest final : public nsResolveHostCallback,
|
||||
RefPtr<nsHostResolver> mResolver;
|
||||
nsCString mHost; // hostname we're resolving
|
||||
nsCString mTrrServer; // A trr server to be used.
|
||||
uint16_t mType;
|
||||
uint16_t mType = 0;
|
||||
const OriginAttributes
|
||||
mOriginAttributes; // The originAttributes for this resolving
|
||||
nsCOMPtr<nsIDNSListener> mListener;
|
||||
uint16_t mFlags;
|
||||
uint16_t mAF;
|
||||
uint16_t mFlags = 0;
|
||||
uint16_t mAF = 0;
|
||||
|
||||
private:
|
||||
virtual ~nsDNSAsyncRequest() = default;
|
||||
@ -534,21 +533,20 @@ nsDNSAsyncRequest::Cancel(nsresult reason) {
|
||||
class nsDNSSyncRequest : public nsResolveHostCallback {
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
public:
|
||||
explicit nsDNSSyncRequest(PRMonitor* mon)
|
||||
: mDone(false), mStatus(NS_OK), mMonitor(mon) {}
|
||||
explicit nsDNSSyncRequest(PRMonitor* mon) : mMonitor(mon) {}
|
||||
|
||||
void OnResolveHostComplete(nsHostResolver*, nsHostRecord*, nsresult) override;
|
||||
bool EqualsAsyncListener(nsIDNSListener* aListener) override;
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf) const override;
|
||||
|
||||
bool mDone;
|
||||
nsresult mStatus;
|
||||
bool mDone = false;
|
||||
nsresult mStatus = NS_OK;
|
||||
RefPtr<nsHostRecord> mHostRecord;
|
||||
|
||||
private:
|
||||
virtual ~nsDNSSyncRequest() = default;
|
||||
|
||||
PRMonitor* mMonitor;
|
||||
PRMonitor* mMonitor = nullptr;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS0(nsDNSSyncRequest)
|
||||
@ -604,23 +602,6 @@ class NotifyDNSResolution : public Runnable {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
nsDNSService::nsDNSService()
|
||||
: mLock("nsDNSServer.mLock"),
|
||||
mDisableIPv6(false),
|
||||
mDisablePrefetch(false),
|
||||
mBlockDotOnion(false),
|
||||
mNotifyResolution(false),
|
||||
mOfflineLocalhost(false),
|
||||
mForceResolveOn(false),
|
||||
mTrrService(nullptr),
|
||||
mHasSocksProxy(false),
|
||||
mResCacheEntries(0),
|
||||
mResCacheExpiration(0),
|
||||
mResCacheGrace(0),
|
||||
mResolverPrefsUpdated(false) {}
|
||||
|
||||
nsDNSService::~nsDNSService() = default;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsDNSService, nsIDNSService, nsPIDNSService, nsIObserver,
|
||||
nsIMemoryReporter)
|
||||
|
||||
|
@ -32,7 +32,7 @@ class nsDNSService final : public nsPIDNSService,
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIMEMORYREPORTER
|
||||
|
||||
nsDNSService();
|
||||
nsDNSService() = default;
|
||||
|
||||
static already_AddRefed<nsIDNSService> GetXPCOMSingleton();
|
||||
|
||||
@ -49,7 +49,7 @@ class nsDNSService final : public nsPIDNSService,
|
||||
nsIDNSRecord** result);
|
||||
|
||||
private:
|
||||
~nsDNSService();
|
||||
~nsDNSService() = default;
|
||||
|
||||
nsresult ReadPrefs(const char* name);
|
||||
static already_AddRefed<nsDNSService> GetSingleton();
|
||||
@ -85,27 +85,27 @@ class nsDNSService final : public nsPIDNSService,
|
||||
|
||||
// mLock protects access to mResolver, mLocalDomains, mIPv4OnlyDomains and
|
||||
// mFailedSVCDomainNames
|
||||
mozilla::Mutex mLock;
|
||||
mozilla::Mutex mLock{"nsDNSServer.mLock"};
|
||||
|
||||
// mIPv4OnlyDomains is a comma-separated list of domains for which only
|
||||
// IPv4 DNS lookups are performed. This allows the user to disable IPv6 on
|
||||
// a per-domain basis and work around broken DNS servers. See bug 68796.
|
||||
nsCString mIPv4OnlyDomains;
|
||||
nsCString mForceResolve;
|
||||
bool mDisableIPv6;
|
||||
bool mDisablePrefetch;
|
||||
bool mBlockDotOnion;
|
||||
bool mNotifyResolution;
|
||||
bool mOfflineLocalhost;
|
||||
bool mForceResolveOn;
|
||||
bool mDisableIPv6 = false;
|
||||
bool mDisablePrefetch = false;
|
||||
bool mBlockDotOnion = false;
|
||||
bool mNotifyResolution = false;
|
||||
bool mOfflineLocalhost = false;
|
||||
bool mForceResolveOn = false;
|
||||
nsTHashSet<nsCString> mLocalDomains;
|
||||
RefPtr<mozilla::net::TRRService> mTrrService;
|
||||
mozilla::Atomic<bool, mozilla::Relaxed> mHasSocksProxy;
|
||||
mozilla::Atomic<bool, mozilla::Relaxed> mHasSocksProxy{false};
|
||||
|
||||
uint32_t mResCacheEntries;
|
||||
uint32_t mResCacheExpiration;
|
||||
uint32_t mResCacheGrace;
|
||||
bool mResolverPrefsUpdated;
|
||||
uint32_t mResCacheEntries = 0;
|
||||
uint32_t mResCacheExpiration = 0;
|
||||
uint32_t mResCacheGrace = 0;
|
||||
bool mResolverPrefsUpdated = false;
|
||||
bool mODoHActivated = false;
|
||||
nsClassHashtable<nsCStringHashKey, nsTArray<nsCString>> mFailedSVCDomainNames;
|
||||
};
|
||||
|
@ -197,12 +197,7 @@ size_t nsHostKey::SizeOfExcludingThis(
|
||||
NS_IMPL_ISUPPORTS0(nsHostRecord)
|
||||
|
||||
nsHostRecord::nsHostRecord(const nsHostKey& key)
|
||||
: nsHostKey(key),
|
||||
mEffectiveTRRMode(nsIRequest::TRR_DEFAULT_MODE),
|
||||
mTRRQuery("nsHostRecord.mTRRQuery"),
|
||||
mResolving(0),
|
||||
negative(false),
|
||||
mDoomed(false) {}
|
||||
: nsHostKey(key), mTRRQuery("nsHostRecord.mTRRQuery") {}
|
||||
|
||||
void nsHostRecord::Invalidate() { mDoomed = true; }
|
||||
|
||||
@ -290,15 +285,7 @@ static size_t SizeOfResolveHostCallbackListExcludingHead(
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(AddrHostRecord, nsHostRecord, AddrHostRecord)
|
||||
|
||||
AddrHostRecord::AddrHostRecord(const nsHostKey& key)
|
||||
: nsHostRecord(key),
|
||||
addr_info_lock("AddrHostRecord.addr_info_lock"),
|
||||
addr_info_gencnt(0),
|
||||
addr_info(nullptr),
|
||||
addr(nullptr),
|
||||
mResolverType(DNSResolverType::Native),
|
||||
mTRRSuccess(0),
|
||||
mNativeSuccess(0) {}
|
||||
AddrHostRecord::AddrHostRecord(const nsHostKey& key) : nsHostRecord(key) {}
|
||||
|
||||
AddrHostRecord::~AddrHostRecord() {
|
||||
mCallbacks.clear();
|
||||
@ -511,10 +498,7 @@ NS_IMPL_ISUPPORTS_INHERITED(TypeHostRecord, nsHostRecord, TypeHostRecord,
|
||||
nsIDNSTXTRecord, nsIDNSHTTPSSVCRecord)
|
||||
|
||||
TypeHostRecord::TypeHostRecord(const nsHostKey& key)
|
||||
: nsHostRecord(key),
|
||||
DNSHTTPSSVCRecordBase(key.host),
|
||||
mResultsLock("TypeHostRecord.mResultsLock"),
|
||||
mAllRecordsExcluded(false) {}
|
||||
: nsHostRecord(key), DNSHTTPSSVCRecordBase(key.host) {}
|
||||
|
||||
TypeHostRecord::~TypeHostRecord() { mCallbacks.clear(); }
|
||||
|
||||
@ -692,14 +676,7 @@ nsHostResolver::nsHostResolver(uint32_t maxCacheEntries,
|
||||
: mMaxCacheEntries(maxCacheEntries),
|
||||
mDefaultCacheLifetime(defaultCacheEntryLifetime),
|
||||
mDefaultGracePeriod(defaultGracePeriod),
|
||||
mLock("nsHostResolver.mLock"),
|
||||
mIdleTaskCV(mLock, "nsHostResolver.mIdleTaskCV"),
|
||||
mEvictionQSize(0),
|
||||
mShutdown(true),
|
||||
mNumIdleTasks(0),
|
||||
mActiveTaskCount(0),
|
||||
mActiveAnyThreadCount(0),
|
||||
mPendingCount(0) {
|
||||
mIdleTaskCV(mLock, "nsHostResolver.mIdleTaskCV") {
|
||||
mCreationTime = PR_Now();
|
||||
|
||||
mLongIdleTimeout = TimeDuration::FromSeconds(LongIdleTimeoutSeconds);
|
||||
@ -2157,7 +2134,6 @@ void nsHostResolver::CancelAsyncRequest(
|
||||
nsHostKey key(host, aTrrServer, aType, flags, af,
|
||||
(aOriginAttributes.mPrivateBrowsingId > 0), originSuffix);
|
||||
RefPtr<nsHostRecord> rec = mRecordDB.Get(key);
|
||||
|
||||
if (!rec) {
|
||||
return;
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ extern mozilla::Atomic<bool, mozilla::Relaxed> gNativeIsLocalhost;
|
||||
struct nsHostKey {
|
||||
const nsCString host;
|
||||
const nsCString mTrrServer;
|
||||
uint16_t type;
|
||||
uint16_t flags;
|
||||
uint16_t af;
|
||||
bool pb;
|
||||
uint16_t type = 0;
|
||||
uint16_t flags = 0;
|
||||
uint16_t af = 0;
|
||||
bool pb = false;
|
||||
const nsCString originSuffix;
|
||||
explicit nsHostKey(const nsACString& host, const nsACString& aTrrServer,
|
||||
uint16_t type, uint16_t flags, uint16_t af, bool pb,
|
||||
@ -159,7 +159,7 @@ class nsHostRecord : public mozilla::LinkedListElement<RefPtr<nsHostRecord>>,
|
||||
// default resolver and the TRRMode encoded in the flags.
|
||||
// The mode into account if the TRR service is disabled,
|
||||
// parental controls are on, domain matches exclusion list, etc.
|
||||
nsIRequest::TRRMode mEffectiveTRRMode;
|
||||
nsIRequest::TRRMode mEffectiveTRRMode = nsIRequest::TRR_DEFAULT_MODE;
|
||||
|
||||
TRRSkippedReason mTRRSkippedReason = TRRSkippedReason::TRR_UNSET;
|
||||
TRRSkippedReason mTRRAFailReason = TRRSkippedReason::TRR_UNSET;
|
||||
@ -167,15 +167,16 @@ class nsHostRecord : public mozilla::LinkedListElement<RefPtr<nsHostRecord>>,
|
||||
|
||||
mozilla::DataMutex<RefPtr<mozilla::net::TRRQuery>> mTRRQuery;
|
||||
|
||||
mozilla::Atomic<int32_t>
|
||||
mResolving; // counter of outstanding resolving calls
|
||||
// counter of outstanding resolving calls
|
||||
mozilla::Atomic<int32_t> mResolving{0};
|
||||
|
||||
uint8_t negative : 1; /* True if this record is a cache of a failed
|
||||
lookup. Negative cache entries are valid just
|
||||
like any other (though never for more than 60
|
||||
seconds), but a use of that negative entry
|
||||
forces an asynchronous refresh. */
|
||||
uint8_t mDoomed : 1; // explicitly expired
|
||||
// True if this record is a cache of a failed lookup. Negative cache
|
||||
// entries are valid just like any other (though never for more than 60
|
||||
// seconds), but a use of that negative entry forces an asynchronous refresh.
|
||||
bool negative = false;
|
||||
|
||||
// Explicitly expired
|
||||
bool mDoomed = false;
|
||||
};
|
||||
|
||||
// b020e996-f6ab-45e5-9bf5-1da71dd0053a
|
||||
@ -188,6 +189,7 @@ class nsHostRecord : public mozilla::LinkedListElement<RefPtr<nsHostRecord>>,
|
||||
|
||||
class AddrHostRecord final : public nsHostRecord {
|
||||
using Mutex = mozilla::Mutex;
|
||||
using DNSResolverType = mozilla::net::DNSResolverType;
|
||||
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(ADDRHOSTRECORD_IID)
|
||||
@ -210,8 +212,9 @@ class AddrHostRecord final : public nsHostRecord {
|
||||
* the other threads just read it. therefore the resolver worker
|
||||
* thread doesn't need to lock when reading |addr_info|.
|
||||
*/
|
||||
Mutex addr_info_lock;
|
||||
int addr_info_gencnt; /* generation count of |addr_info| */
|
||||
Mutex addr_info_lock{"AddrHostRecord.addr_info_lock"};
|
||||
// generation count of |addr_info|
|
||||
int addr_info_gencnt = 0;
|
||||
RefPtr<mozilla::net::AddrInfo> addr_info;
|
||||
mozilla::UniquePtr<mozilla::net::NetAddr> addr;
|
||||
|
||||
@ -257,9 +260,9 @@ class AddrHostRecord final : public nsHostRecord {
|
||||
mozilla::TimeDuration mNativeDuration;
|
||||
|
||||
// TRR or ODoH was used on this record
|
||||
mozilla::Atomic<mozilla::net::DNSResolverType> mResolverType;
|
||||
uint8_t mTRRSuccess; // number of successful TRR responses
|
||||
uint8_t mNativeSuccess; // number of native lookup responses
|
||||
mozilla::Atomic<DNSResolverType> mResolverType{DNSResolverType::Native};
|
||||
uint8_t mTRRSuccess = 0; // number of successful TRR responses
|
||||
uint8_t mNativeSuccess = 0; // number of native lookup responses
|
||||
|
||||
// clang-format off
|
||||
MOZ_ATOMIC_BITFIELDS(mAtomicBitfields, 8, (
|
||||
@ -321,7 +324,7 @@ class TypeHostRecord final : public nsHostRecord,
|
||||
bool HasUsableResult();
|
||||
|
||||
mozilla::net::TypeRecordResultType mResults = AsVariant(mozilla::Nothing());
|
||||
mozilla::Mutex mResultsLock;
|
||||
mozilla::Mutex mResultsLock{"TypeHostRecord.mResultsLock"};
|
||||
|
||||
// When the lookups of this record started (for telemetry).
|
||||
mozilla::TimeStamp mStart;
|
||||
@ -584,17 +587,18 @@ class nsHostResolver : public nsISupports, public AHostResolver {
|
||||
METHOD_NETWORK_SHARED = 7
|
||||
};
|
||||
|
||||
uint32_t mMaxCacheEntries;
|
||||
uint32_t mDefaultCacheLifetime; // granularity seconds
|
||||
uint32_t mDefaultGracePeriod; // granularity seconds
|
||||
mutable Mutex mLock; // mutable so SizeOfIncludingThis can be const
|
||||
uint32_t mMaxCacheEntries = 0;
|
||||
uint32_t mDefaultCacheLifetime = 0; // granularity seconds
|
||||
uint32_t mDefaultGracePeriod = 0; // granularity seconds
|
||||
// mutable so SizeOfIncludingThis can be const
|
||||
mutable Mutex mLock{"nsHostResolver.mLock"};
|
||||
CondVar mIdleTaskCV;
|
||||
nsRefPtrHashtable<nsGenericHashKey<nsHostKey>, nsHostRecord> mRecordDB;
|
||||
mozilla::LinkedList<RefPtr<nsHostRecord>> mHighQ;
|
||||
mozilla::LinkedList<RefPtr<nsHostRecord>> mMediumQ;
|
||||
mozilla::LinkedList<RefPtr<nsHostRecord>> mLowQ;
|
||||
mozilla::LinkedList<RefPtr<nsHostRecord>> mEvictionQ;
|
||||
uint32_t mEvictionQSize;
|
||||
uint32_t mEvictionQSize = 0;
|
||||
PRTime mCreationTime;
|
||||
mozilla::TimeDuration mLongIdleTimeout;
|
||||
mozilla::TimeDuration mShortIdleTimeout;
|
||||
@ -602,11 +606,11 @@ class nsHostResolver : public nsISupports, public AHostResolver {
|
||||
RefPtr<nsIThreadPool> mResolverThreads;
|
||||
RefPtr<mozilla::net::NetworkConnectivityService> mNCS;
|
||||
|
||||
mozilla::Atomic<bool> mShutdown;
|
||||
mozilla::Atomic<uint32_t> mNumIdleTasks;
|
||||
mozilla::Atomic<uint32_t> mActiveTaskCount;
|
||||
mozilla::Atomic<uint32_t> mActiveAnyThreadCount;
|
||||
mozilla::Atomic<uint32_t> mPendingCount;
|
||||
mozilla::Atomic<bool> mShutdown{true};
|
||||
mozilla::Atomic<uint32_t> mNumIdleTasks{0};
|
||||
mozilla::Atomic<uint32_t> mActiveTaskCount{0};
|
||||
mozilla::Atomic<uint32_t> mActiveAnyThreadCount{0};
|
||||
mozilla::Atomic<uint32_t> mPendingCount{0};
|
||||
|
||||
// Set the expiration time stamps appropriately.
|
||||
void PrepareRecordExpirationAddrRecord(AddrHostRecord* rec) const;
|
||||
|
@ -133,11 +133,7 @@ void nsIDNService::prefsChanged(const char* pref) {
|
||||
}
|
||||
}
|
||||
|
||||
nsIDNService::nsIDNService()
|
||||
: mLock("DNService pref value lock"),
|
||||
mShowPunycode(false),
|
||||
mRestrictionProfile(static_cast<restrictionProfile>(0)),
|
||||
mIDNUseWhitelist(false) {
|
||||
nsIDNService::nsIDNService() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
uint32_t IDNAOptions = UIDNA_CHECK_BIDI | UIDNA_CHECK_CONTEXTJ;
|
||||
@ -387,10 +383,11 @@ NS_IMETHODIMP nsIDNService::Normalize(const nsACString& input,
|
||||
namespace {
|
||||
|
||||
class MOZ_STACK_CLASS MutexSettableAutoUnlock final {
|
||||
Mutex* mMutex;
|
||||
private:
|
||||
Mutex* mMutex = nullptr;
|
||||
|
||||
public:
|
||||
MutexSettableAutoUnlock() : mMutex(nullptr) {}
|
||||
MutexSettableAutoUnlock() = default;
|
||||
|
||||
void Acquire(mozilla::Mutex& aMutex) {
|
||||
MOZ_ASSERT(!mMutex);
|
||||
|
@ -170,7 +170,7 @@ class nsIDNService final : public nsIIDNService,
|
||||
// These members can only be updated on the main thread and
|
||||
// read on any thread. Therefore, acquiring the mutex is required
|
||||
// only for threads other than the main thread.
|
||||
mozilla::Mutex mLock;
|
||||
mozilla::Mutex mLock{"IDNService"};
|
||||
|
||||
// guarded by mLock
|
||||
nsTArray<mozilla::net::BlocklistRange> mIDNBlocklist;
|
||||
@ -182,7 +182,7 @@ class nsIDNService final : public nsIIDNService,
|
||||
*
|
||||
* guarded by mLock
|
||||
*/
|
||||
bool mShowPunycode;
|
||||
bool mShowPunycode = false;
|
||||
|
||||
/**
|
||||
* Restriction-level Detection profiles defined in UTR 39
|
||||
@ -195,11 +195,11 @@ class nsIDNService final : public nsIIDNService,
|
||||
eModeratelyRestrictiveProfile
|
||||
};
|
||||
// guarded by mLock;
|
||||
restrictionProfile mRestrictionProfile;
|
||||
restrictionProfile mRestrictionProfile{eASCIIOnlyProfile};
|
||||
// guarded by mLock;
|
||||
nsCOMPtr<nsIPrefBranch> mIDNWhitelistPrefBranch;
|
||||
// guarded by mLock
|
||||
bool mIDNUseWhitelist;
|
||||
bool mIDNUseWhitelist = false;
|
||||
};
|
||||
|
||||
#endif // nsIDNService_h__
|
||||
|
Loading…
Reference in New Issue
Block a user