mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 957759 - Remove SRV experiment code (helps prevent crashes). r=mcmanus
This commit is contained in:
parent
7b59f8d90b
commit
6480bda07a
@ -797,11 +797,6 @@ pref("security.fileuri.strict_origin_policy", true);
|
||||
// telemetry is also enabled as otherwise there is no way to report
|
||||
// the results
|
||||
pref("network.allow-experiments", true);
|
||||
#if defined(EARLY_BETA_OR_EARLIER)
|
||||
pref("network.dns.allow-srv-experiment", true);
|
||||
#else
|
||||
pref("network.dns.allow-srv-experiment", false);
|
||||
#endif
|
||||
|
||||
// Transmit UDP busy-work to the LAN when anticipating low latency
|
||||
// network reads and on wifi to mitigate 802.11 Power Save Polling delays
|
||||
|
@ -35,10 +35,6 @@
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/VisualEventTracer.h"
|
||||
#if defined(XP_WIN)
|
||||
// See bug 942317 in case you're all "WTF, mate?!"
|
||||
#include "mozilla/Preferences.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::net;
|
||||
@ -429,13 +425,6 @@ nsHostResolver::nsHostResolver(uint32_t maxCacheEntries,
|
||||
, mEvictionQSize(0)
|
||||
, mPendingCount(0)
|
||||
, mShutdown(true)
|
||||
#if defined(XP_WIN)
|
||||
// See bug 942317 in case you're all "WTF, mate?!"
|
||||
, mExperimentLock("nsHostResolver.mExperimentLock")
|
||||
, mHasRunExperiment(false)
|
||||
, mNetworkExperimentsOK(true)
|
||||
, mDnsExperimentOK(true)
|
||||
#endif
|
||||
{
|
||||
mCreationTime = PR_Now();
|
||||
PR_INIT_CLIST(&mHighQ);
|
||||
@ -471,21 +460,6 @@ nsHostResolver::Init()
|
||||
res_ninit(&_res);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN)
|
||||
// See bug 942317 in case you're all "WTF, mate?!"
|
||||
Preferences::AddBoolVarCache(&mNetworkExperimentsOK,
|
||||
"network.allow-experiments",
|
||||
true);
|
||||
Preferences::AddBoolVarCache(&mDnsExperimentOK,
|
||||
"network.dns.allow-srv-experiment",
|
||||
#if defined(EARLY_BETA_OR_EARLIER)
|
||||
true
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -869,335 +843,11 @@ nsHostResolver::ConditionallyCreateThread(nsHostRecord *rec)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if defined(XP_WIN)
|
||||
// See bug 942317 in case you're all "WTF, mate?!"
|
||||
#include "nsID.h"
|
||||
#include "nsIUUIDGenerator.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "prlink.h"
|
||||
#include "windns.h"
|
||||
#include "windows.h"
|
||||
|
||||
typedef DNS_STATUS (__stdcall * DnsQueryFunc) (LPCSTR lpstrName, WORD wType,
|
||||
DWORD Options, PVOID pExtra,
|
||||
PDNS_RECORDA *ppQueryResultsSet,
|
||||
PVOID *pReserved);
|
||||
|
||||
class ExperimentFinishedRunner : public nsRunnable
|
||||
{
|
||||
public:
|
||||
ExperimentFinishedRunner(nsIThread *thread)
|
||||
:mThread(thread)
|
||||
{ }
|
||||
|
||||
~ExperimentFinishedRunner()
|
||||
{ }
|
||||
|
||||
NS_IMETHOD Run() MOZ_OVERRIDE
|
||||
{
|
||||
mThread->Shutdown();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIThread> mThread;
|
||||
};
|
||||
|
||||
class ExperimentResolver : public nsRunnable
|
||||
{
|
||||
public:
|
||||
ExperimentResolver(WORD queryType, nsACString &uuid, HANDLE *event,
|
||||
TimeStamp *start, TimeStamp *end, DNS_STATUS *status,
|
||||
DNS_RECORDA **results, DnsQueryFunc dnsQuery)
|
||||
:mQueryType(queryType)
|
||||
,mUUID(uuid)
|
||||
,mEvent(event)
|
||||
,mStart(start)
|
||||
,mEnd(end)
|
||||
,mStatus(status)
|
||||
,mResults(results)
|
||||
,mDnsQuery(dnsQuery)
|
||||
{ }
|
||||
|
||||
~ExperimentResolver()
|
||||
{ }
|
||||
|
||||
NS_IMETHOD Run() MOZ_OVERRIDE
|
||||
{
|
||||
nsAutoCString name;
|
||||
if (mQueryType == DNS_TYPE_SRV) {
|
||||
name.Assign(NS_LITERAL_CSTRING("_http2tls.srv-"));
|
||||
} else {
|
||||
name.Assign(NS_LITERAL_CSTRING("a-"));
|
||||
}
|
||||
name.Append(mUUID);
|
||||
name.Append(NS_LITERAL_CSTRING(".http2test.mozilla.org"));
|
||||
|
||||
*mStart = mozilla::TimeStamp::Now();
|
||||
*mStatus = mDnsQuery(name.get(), mQueryType, DNS_QUERY_STANDARD,
|
||||
nullptr, mResults, nullptr);
|
||||
*mEnd = mozilla::TimeStamp::Now();
|
||||
|
||||
SetEvent(*mEvent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
WORD mQueryType;
|
||||
nsAutoCString mUUID;
|
||||
HANDLE *mEvent;
|
||||
TimeStamp *mStart;
|
||||
TimeStamp *mEnd;
|
||||
DNS_STATUS *mStatus;
|
||||
DNS_RECORDA **mResults;
|
||||
DnsQueryFunc mDnsQuery;
|
||||
};
|
||||
|
||||
class ExperimentRunner : public nsRunnable
|
||||
{
|
||||
public:
|
||||
ExperimentRunner(nsIThread *experimentThread, nsIThread *resolveAThread,
|
||||
nsIThread *resolveSRVThread)
|
||||
:mExperimentThread(experimentThread)
|
||||
,mResolveAThread(resolveAThread)
|
||||
,mResolveSRVThread(resolveSRVThread)
|
||||
{ }
|
||||
|
||||
~ExperimentRunner()
|
||||
{ }
|
||||
|
||||
NS_IMETHOD Run() MOZ_OVERRIDE
|
||||
{
|
||||
// These are all declared here because compiler warnings about goto.
|
||||
DnsQueryFunc dnsQuery;
|
||||
TimeStamp startALookup, endALookup, startSRVLookup, endSRVLookup;
|
||||
DNS_RECORDA *aResults = nullptr, *srvResults = nullptr;
|
||||
DNS_STATUS aStatus, srvStatus;
|
||||
int32_t experimentStatus;
|
||||
Telemetry::ID deltaKey;
|
||||
TimeDuration duration;
|
||||
double delta;
|
||||
uint32_t timeDelta;
|
||||
nsresult rv;
|
||||
nsID id;
|
||||
char uuid[NSID_LENGTH];
|
||||
nsAutoCString dnsUUID;
|
||||
nsCOMPtr<nsIUUIDGenerator> uuidgen;
|
||||
HANDLE events[2];
|
||||
bool correctA = true, correctSRV = true;
|
||||
|
||||
PRLibrary *lib = PR_LoadLibrary("Dnsapi.dll");
|
||||
if (!lib) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
dnsQuery = (DnsQueryFunc) PR_FindFunctionSymbol(lib, "DnsQuery_A");
|
||||
if (!dnsQuery) {
|
||||
goto library_cleanup;
|
||||
}
|
||||
|
||||
// Generate hostnames that are subhosts of aus.mozilla.org, as we want
|
||||
// to make sure that whatever hostname we lookup will not be cached
|
||||
// anywhere. Use separate names for the A and SRV lookups to ensure that
|
||||
// Windows doesn't do any odd caching of NXDOMAIN in case the A lookup
|
||||
// fails.
|
||||
uuidgen = do_GetService("@mozilla.org/uuid-generator;1", &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto library_cleanup;
|
||||
}
|
||||
rv = uuidgen->GenerateUUIDInPlace(&id);
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
id.ToProvidedString(uuid);
|
||||
// Strip off the { and } surrounding the UUID string
|
||||
dnsUUID.Assign(Substring(nsDependentCString(uuid), 1, NSID_LENGTH - 3));
|
||||
|
||||
// Create events for A and SRV resolvers
|
||||
events[0] = CreateEvent(nullptr, TRUE, FALSE, TEXT("FinishedA"));
|
||||
if (!events[0]) {
|
||||
goto library_cleanup;
|
||||
}
|
||||
|
||||
events[1] = CreateEvent(nullptr, TRUE, FALSE, TEXT("FinishedSRV"));
|
||||
if (!events[1]) {
|
||||
goto aevent_cleanup;
|
||||
}
|
||||
|
||||
// dispatch A resolver
|
||||
mResolveAThread->Dispatch(new ExperimentResolver(DNS_TYPE_A,
|
||||
dnsUUID,
|
||||
&events[0],
|
||||
&startALookup,
|
||||
&endALookup,
|
||||
&aStatus,
|
||||
&aResults,
|
||||
dnsQuery),
|
||||
NS_DISPATCH_NORMAL);
|
||||
|
||||
// dispatch SRV resolver
|
||||
mResolveSRVThread->Dispatch(new ExperimentResolver(DNS_TYPE_SRV,
|
||||
dnsUUID,
|
||||
&events[1],
|
||||
&startSRVLookup,
|
||||
&endSRVLookup,
|
||||
&srvStatus,
|
||||
&srvResults,
|
||||
dnsQuery),
|
||||
NS_DISPATCH_NORMAL);
|
||||
|
||||
WaitForMultipleObjects(2, events, TRUE, INFINITE);
|
||||
|
||||
// Ensure we got the expected results
|
||||
if (aStatus == DNS_RCODE_NOERROR) {
|
||||
if (!aResults) {
|
||||
// Mark this as failed, since we didn't get a result back
|
||||
aStatus = !DNS_RCODE_NOERROR;
|
||||
} else if (aResults->Data.A.IpAddress != 0x7F000001) {
|
||||
correctA = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (srvStatus == DNS_RCODE_NOERROR) {
|
||||
if (srvResults) {
|
||||
DNS_SRV_DATAA *srvData = &srvResults->Data.Srv;
|
||||
if (_stricmp(srvData->pNameTarget, "success.http2test.mozilla.org") ||
|
||||
srvData->wPort != 443 ||
|
||||
srvData->wPriority != 100 ||
|
||||
srvData->wWeight != 100) {
|
||||
correctSRV = false;
|
||||
}
|
||||
} else {
|
||||
// Mark this as failed, since we didn't get a result back
|
||||
srvStatus = !DNS_RCODE_NOERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (aStatus == DNS_RCODE_NOERROR && srvStatus == DNS_RCODE_NOERROR) {
|
||||
experimentStatus = kBothSucceed;
|
||||
deltaKey = Telemetry::SRV_EXPERIMENT_SUCCESS_DELTA;
|
||||
Telemetry::Accumulate(Telemetry::SRV_EXPERIMENT_A_CORRECT, correctA);
|
||||
Telemetry::Accumulate(Telemetry::SRV_EXPERIMENT_SRV_CORRECT, correctSRV);
|
||||
} else if (aStatus == DNS_RCODE_NOERROR) {
|
||||
experimentStatus = kSRVFail;
|
||||
deltaKey = Telemetry::SRV_EXPERIMENT_SRV_FAIL_DELTA;
|
||||
Telemetry::Accumulate(Telemetry::SRV_EXPERIMENT_SRV_CORRECT, correctSRV);
|
||||
} else if (srvStatus == DNS_RCODE_NOERROR) {
|
||||
experimentStatus = kAFail;
|
||||
deltaKey = Telemetry::SRV_EXPERIMENT_A_FAIL_DELTA;
|
||||
Telemetry::Accumulate(Telemetry::SRV_EXPERIMENT_A_CORRECT, correctA);
|
||||
} else { // aStatus != DNS_RCODE_NOERROR && srvStatus != DNS_RCODE_NOERROR
|
||||
experimentStatus = kBothFail;
|
||||
deltaKey = Telemetry::SRV_EXPERIMENT_FAIL_DELTA;
|
||||
// Neither one succeeded, so our correctness flags are irrelevant
|
||||
}
|
||||
|
||||
Telemetry::Accumulate(Telemetry::SRV_EXPERIMENT_STATUS,
|
||||
experimentStatus);
|
||||
Telemetry::AccumulateTimeDelta(Telemetry::SRV_EXPERIMENT_SRV_TIME,
|
||||
startSRVLookup, endSRVLookup);
|
||||
Telemetry::AccumulateTimeDelta(Telemetry::SRV_EXPERIMENT_A_TIME,
|
||||
startALookup, endALookup);
|
||||
|
||||
// Calculate time delta in ms clamped to [0, 2000] where 1000 means both
|
||||
// lookups took the same amount of time, 0-999 means the SRV record came
|
||||
// back faster, and 1001-2000 means the A record came back faster.
|
||||
duration = (endALookup - startALookup) - (endSRVLookup - startSRVLookup);
|
||||
delta = duration.ToMilliseconds();
|
||||
if (delta < -1000.0) {
|
||||
delta = -1000.0;
|
||||
} else if (delta > 1000.0) {
|
||||
delta = 1000.0;
|
||||
}
|
||||
|
||||
timeDelta = static_cast<uint32_t>(delta) + 1000;
|
||||
Telemetry::Accumulate(deltaKey, timeDelta);
|
||||
|
||||
mResolveSRVThread->Shutdown();
|
||||
mResolveAThread->Shutdown();
|
||||
CloseHandle(events[1]);
|
||||
aevent_cleanup:
|
||||
CloseHandle(events[0]);
|
||||
// Do the library cleanup here to avoid doing I/O on the main thread
|
||||
library_cleanup:
|
||||
dnsQuery = nullptr;
|
||||
PR_UnloadLibrary(lib);
|
||||
out:
|
||||
NS_DispatchToMainThread(new ExperimentFinishedRunner(mExperimentThread));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIThread> mExperimentThread;
|
||||
nsCOMPtr<nsIThread> mResolveAThread;
|
||||
nsCOMPtr<nsIThread> mResolveSRVThread;
|
||||
static const uint32_t kBothSucceed = 0;
|
||||
static const uint32_t kSRVFail = 1;
|
||||
static const uint32_t kAFail = 2;
|
||||
static const uint32_t kBothFail = 3;
|
||||
};
|
||||
|
||||
void
|
||||
nsHostResolver::RunExperiment()
|
||||
{
|
||||
if (!NS_IsMainThread()) {
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mExperimentLock);
|
||||
if (mHasRunExperiment) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHasRunExperiment = true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIThread> experimentThread;
|
||||
NS_NewNamedThread("SRV Experiment", getter_AddRefs(experimentThread));
|
||||
if (!experimentThread) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create threads for A and SRV resolvers
|
||||
nsCOMPtr<nsIThread> resolveAThread;
|
||||
NS_NewNamedThread("Experiment A", getter_AddRefs(resolveAThread));
|
||||
if (!resolveAThread) {
|
||||
experimentThread->Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIThread> resolveSRVThread;
|
||||
NS_NewNamedThread("Experiment SRV", getter_AddRefs(resolveSRVThread));
|
||||
if (!resolveSRVThread) {
|
||||
resolveAThread->Shutdown();
|
||||
experimentThread->Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
experimentThread->Dispatch(new ExperimentRunner(experimentThread,
|
||||
resolveAThread,
|
||||
resolveSRVThread),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
nsHostResolver::IssueLookup(nsHostRecord *rec)
|
||||
{
|
||||
MOZ_EVENT_TRACER_WAIT(rec, "net::dns::resolve");
|
||||
|
||||
#if defined(XP_WIN)
|
||||
// See bug 942317 in case you're all "WTF, mate?!"
|
||||
if (mNetworkExperimentsOK && mDnsExperimentOK && Telemetry::CanRecord() &&
|
||||
!mHasRunExperiment) {
|
||||
int offset = strlen(rec->host) - strlen(".mozilla.org");
|
||||
if ((offset > 0) && (_stricmp(rec->host + offset, ".mozilla.org") == 0)) {
|
||||
RunExperiment();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
NS_ASSERTION(!rec->resolving, "record is already being resolved");
|
||||
|
||||
|
@ -291,15 +291,6 @@ private:
|
||||
PRIntervalTime mLongIdleTimeout;
|
||||
PRIntervalTime mShortIdleTimeout;
|
||||
|
||||
#if defined(XP_WIN)
|
||||
// See bug 942317 in case you're all "WTF, mate?!"
|
||||
void RunExperiment();
|
||||
Mutex mExperimentLock;
|
||||
bool mHasRunExperiment;
|
||||
bool mNetworkExperimentsOK;
|
||||
bool mDnsExperimentOK;
|
||||
#endif
|
||||
|
||||
public:
|
||||
/*
|
||||
* Called by the networking dashboard via the DnsService2
|
||||
|
@ -2049,66 +2049,6 @@
|
||||
"n_values": 3,
|
||||
"description": "I want to be tracked, I do NOT want to be tracked, DNT unset"
|
||||
},
|
||||
"SRV_EXPERIMENT_SUCCESS_DELTA": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "linear",
|
||||
"high": "2000",
|
||||
"n_buckets": 200,
|
||||
"description": "Time delta between A and SRV records when both succeed. This (srv time in ms - a time in ms) + 1000."
|
||||
},
|
||||
"SRV_EXPERIMENT_SRV_FAIL_DELTA": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "linear",
|
||||
"high": "2000",
|
||||
"n_buckets": 200,
|
||||
"description": "Time delta between A and SRV records when SRV only fails. This (srv time in ms - a time in ms) + 1000."
|
||||
},
|
||||
"SRV_EXPERIMENT_A_FAIL_DELTA": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "linear",
|
||||
"high": "2000",
|
||||
"n_buckets": 200,
|
||||
"description": "Time delta between A and SRV records when A only fails. This (srv time in ms - a time in ms) + 1000."
|
||||
},
|
||||
"SRV_EXPERIMENT_FAIL_DELTA": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "linear",
|
||||
"high": "2000",
|
||||
"n_buckets": 200,
|
||||
"description": "Time delta between A and SRV records when both fail. This (srv time in ms - a time in ms) + 1000."
|
||||
},
|
||||
"SRV_EXPERIMENT_STATUS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "enumerated",
|
||||
"n_values": 4,
|
||||
"description": "Status of SRV experiment (0 - both OK, 1 - SRV fail, 2 - A fail, 3 - both fail)"
|
||||
},
|
||||
"SRV_EXPERIMENT_SRV_TIME": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"high": "60000",
|
||||
"n_buckets": 50,
|
||||
"extended_statistics_ok": true,
|
||||
"description": "How long (in ms) it took to get a result for a SRV record"
|
||||
},
|
||||
"SRV_EXPERIMENT_A_TIME": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"high": "60000",
|
||||
"n_buckets": 50,
|
||||
"extended_statistics_ok": true,
|
||||
"description": "How long (in ms) it took to get a result for an A record"
|
||||
},
|
||||
"SRV_EXPERIMENT_A_CORRECT": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "boolean",
|
||||
"description": "Whether a successful A query returned the results we expected"
|
||||
},
|
||||
"SRV_EXPERIMENT_SRV_CORRECT": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "boolean",
|
||||
"description": "Whether a successful SRV query returned the results we expected"
|
||||
},
|
||||
"DNS_LOOKUP_METHOD2": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "enumerated",
|
||||
|
Loading…
Reference in New Issue
Block a user