Bug 1590528 - Call CheckAdaptersAddresses at startup r=kershaw

The problem is that the suffix is not always computed when Firefox starts up.
This patch adds a pref `network.notify.initial_call` that controls whether
CheckAdaptersAddresses gets called imediately after.
This call is necessary in order to compute the suffix list, VPN status, etc.

This patch also ensures that OnDnsSuffixListUpdated gets called by
NetlinkService::ComputeDNSSuffixList on Android. This notification is
necessary for the TRRService to pick up the suffix list.

Differential Revision: https://phabricator.services.mozilla.com/D55303

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Valentin Gosu 2019-12-02 09:34:14 +00:00
parent 7ae939ccbc
commit 0848f9ba9a
3 changed files with 13 additions and 6 deletions

View File

@ -6940,6 +6940,14 @@
value: true
mirror: always
# Whether NotifyIpInterfaceChange should be called immediately after
# registration in order to record the initial state of the network adapters.
- name: network.notify.initial_call
type: RelaxedAtomicBool
value: true
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "nglayout."
#---------------------------------------------------------------------------

View File

@ -1684,8 +1684,8 @@ bool NetlinkService::CalculateIDForFamily(uint8_t aFamily, SHA1Sum* aSHA1) {
void NetlinkService::ComputeDNSSuffixList() {
MOZ_ASSERT(!NS_IsMainThread(), "Must not be called on the main thread");
#if defined(HAVE_RES_NINIT)
nsTArray<nsCString> suffixList;
#if defined(HAVE_RES_NINIT)
struct __res_state res;
if (res_ninit(&res) == 0) {
for (int i = 0; i < MAXDNSRCH; i++) {
@ -1696,18 +1696,16 @@ void NetlinkService::ComputeDNSSuffixList() {
}
res_nclose(&res);
}
#endif
RefPtr<NetlinkServiceListener> listener;
{
MutexAutoLock lock(mMutex);
listener = mListener;
mDNSSuffixList = std::move(suffixList);
}
if (listener) {
listener->OnDnsSuffixListUpdated();
}
#endif
}
void NetlinkService::UpdateLinkStatus() {

View File

@ -294,8 +294,8 @@ nsNotifyAddrListener::Run() {
StaticPrefs::network_notify_IPv6() ? AF_UNSPEC
: AF_INET, // IPv4 and IPv6
(PIPINTERFACE_CHANGE_CALLBACK)OnInterfaceChange,
this, // pass to callback
false, // no initial notification
this, // pass to callback
StaticPrefs::network_notify_initial_call(), // initial notification
&interfacechange);
if (ret == NO_ERROR) {
@ -416,6 +416,7 @@ nsresult nsNotifyAddrListener::NotifyObservers(const char* aTopic,
DWORD
nsNotifyAddrListener::CheckAdaptersAddresses(void) {
MOZ_ASSERT(!NS_IsMainThread(), "Don't call this on the main thread");
ULONG len = 16384;
PIP_ADAPTER_ADDRESSES adapterList = (PIP_ADAPTER_ADDRESSES)moz_xmalloc(len);