Commit 9cf524f3 authored by Byron Campen [:bwc]'s avatar Byron Campen [:bwc]
Browse files

Bug 1696593: Ensure that the DNS service is initted (on main) before trying to...

Bug 1696593: Ensure that the DNS service is initted (on main) before trying to init NrIceCtx. r=mjf,kershaw,necko-reviewers, a=jcristau

Also add some NS_WARN_IF that helped find the bug.

Differential Revision: https://phabricator.services.mozilla.com/D107508
parent 882b583a
......@@ -41,6 +41,7 @@
#include "mozilla/PublicSSL.h" // For psm::InitializeCipherSuite
#include "nsISocketTransportService.h"
#include "nsDNSService2.h"
#include "nsNetUtil.h" // NS_CheckPortSafety
#include <string>
......@@ -528,6 +529,10 @@ nsresult MediaTransportHandlerSTS::CreateIceCtx(
static bool globalInitDone = false;
if (!globalInitDone) {
// Ensure the DNS service is initted for the first time on main
DebugOnly<RefPtr<nsIDNSService>> dnsService =
RefPtr<nsIDNSService>(nsDNSService::GetXPCOMSingleton());
MOZ_ASSERT(dnsService.value);
mStsThread->Dispatch(
WrapRunnableNM(&NrIceCtx::InitializeGlobals, GetGlobalConfig()),
NS_DISPATCH_NORMAL);
......
......@@ -12,6 +12,7 @@ LOCAL_INCLUDES += [
"/dom/media/webrtc",
"/ipc/chromium/src",
"/media/webrtc",
"/netwerk/dns", # For nsDNSService2.h
"/third_party/libsrtp/src/include",
"/third_party/libwebrtc",
"/third_party/libwebrtc/webrtc",
......
......@@ -92,7 +92,7 @@ nsresult NrIceResolver::Init() {
sts_thread_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
MOZ_ASSERT(NS_SUCCEEDED(rv));
dns_ = do_GetService(NS_DNSSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
if (NS_WARN_IF(NS_FAILED(rv))) {
MOZ_MTLOG(ML_ERROR, "Could not acquire DNS service");
}
return rv;
......
......@@ -40,7 +40,7 @@ already_AddRefed<ChildDNSService> ChildDNSService::GetSingleton() {
XRE_IsContentProcess() || XRE_IsSocketProcess());
if (!gChildDNSService) {
if (!NS_IsMainThread()) {
if (NS_WARN_IF(!NS_IsMainThread())) {
return nullptr;
}
gChildDNSService = new ChildDNSService();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment