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 @@ ...@@ -41,6 +41,7 @@
#include "mozilla/PublicSSL.h" // For psm::InitializeCipherSuite #include "mozilla/PublicSSL.h" // For psm::InitializeCipherSuite
#include "nsISocketTransportService.h" #include "nsISocketTransportService.h"
#include "nsDNSService2.h"
#include "nsNetUtil.h" // NS_CheckPortSafety #include "nsNetUtil.h" // NS_CheckPortSafety
#include <string> #include <string>
...@@ -528,6 +529,10 @@ nsresult MediaTransportHandlerSTS::CreateIceCtx( ...@@ -528,6 +529,10 @@ nsresult MediaTransportHandlerSTS::CreateIceCtx(
static bool globalInitDone = false; static bool globalInitDone = false;
if (!globalInitDone) { 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( mStsThread->Dispatch(
WrapRunnableNM(&NrIceCtx::InitializeGlobals, GetGlobalConfig()), WrapRunnableNM(&NrIceCtx::InitializeGlobals, GetGlobalConfig()),
NS_DISPATCH_NORMAL); NS_DISPATCH_NORMAL);
......
...@@ -12,6 +12,7 @@ LOCAL_INCLUDES += [ ...@@ -12,6 +12,7 @@ LOCAL_INCLUDES += [
"/dom/media/webrtc", "/dom/media/webrtc",
"/ipc/chromium/src", "/ipc/chromium/src",
"/media/webrtc", "/media/webrtc",
"/netwerk/dns", # For nsDNSService2.h
"/third_party/libsrtp/src/include", "/third_party/libsrtp/src/include",
"/third_party/libwebrtc", "/third_party/libwebrtc",
"/third_party/libwebrtc/webrtc", "/third_party/libwebrtc/webrtc",
......
...@@ -92,7 +92,7 @@ nsresult NrIceResolver::Init() { ...@@ -92,7 +92,7 @@ nsresult NrIceResolver::Init() {
sts_thread_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv); sts_thread_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(NS_SUCCEEDED(rv));
dns_ = do_GetService(NS_DNSSERVICE_CONTRACTID, &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"); MOZ_MTLOG(ML_ERROR, "Could not acquire DNS service");
} }
return rv; return rv;
......
...@@ -40,7 +40,7 @@ already_AddRefed<ChildDNSService> ChildDNSService::GetSingleton() { ...@@ -40,7 +40,7 @@ already_AddRefed<ChildDNSService> ChildDNSService::GetSingleton() {
XRE_IsContentProcess() || XRE_IsSocketProcess()); XRE_IsContentProcess() || XRE_IsSocketProcess());
if (!gChildDNSService) { if (!gChildDNSService) {
if (!NS_IsMainThread()) { if (NS_WARN_IF(!NS_IsMainThread())) {
return nullptr; return nullptr;
} }
gChildDNSService = new ChildDNSService(); 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