Bug 1470907 - Call AsyncShutdown for threads at the end of nsHostResolver::ThreadFunc r=froydnj draft
authorValentin Gosu <valentin.gosu@gmail.com>
Tue, 26 Jun 2018 02:54:48 +0200
changeset 810522 5f6f37a630093badae7889ffdd4f10ba4e3d49b7
parent 810379 6e8e861540e6d8c85c73ab7b2afa1f027fb3750c
push id114016
push uservalentin.gosu@gmail.com
push dateTue, 26 Jun 2018 00:55:21 +0000
reviewersfroydnj
bugs1470907
milestone63.0a1
Bug 1470907 - Call AsyncShutdown for threads at the end of nsHostResolver::ThreadFunc r=froydnj MozReview-Commit-ID: 2M8Qn8KDfdx
netwerk/dns/nsHostResolver.cpp
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -1857,16 +1857,20 @@ nsHostResolver::ThreadFunc()
         if (LOOKUP_RESOLVEAGAIN == CompleteLookup(rec, status, ai, rec->pb)) {
             // leave 'rec' assigned and loop to make a renewed host resolve
             LOG(("DNS lookup thread - Re-resolving host [%s].\n", rec->host.get()));
         } else {
             rec = nullptr;
         }
     } while(true);
 
+    nsCOMPtr<nsIThread> thread = NS_GetCurrentThread();
+    NS_DispatchToMainThread(NS_NewRunnableFunction("nsHostResolver::ThreadFunc::AsyncShutdown", [thread]() {
+        thread->AsyncShutdown();
+    }));
     mThreadCount--;
     LOG(("DNS lookup thread - queue empty, thread finished.\n"));
 }
 
 void
 nsHostResolver::SetCacheLimits(uint32_t aMaxCacheEntries,
                                uint32_t aDefaultCacheEntryLifetime,
                                uint32_t aDefaultGracePeriod)