Bug 1231975 - Part 3: Break a reference cycle between PendingResolution and DNSRequestChild. r=drno
☠☠ backed out by a8d0cda0ef76 ☠ ☠
authorByron Campen [:bwc] <docfaraday@gmail.com>
Thu, 07 Apr 2016 13:12:54 -0500
changeset 335981 7092e498ac3af20998b35a7cadfff4c03d396378
parent 335980 29dce05596c6c854af6f2e71fdfde138033ac1a3
child 335982 408df9f8469753cb2fcc78a2cf5ef4a604101d77
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrno
bugs1231975
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1231975 - Part 3: Break a reference cycle between PendingResolution and DNSRequestChild. r=drno MozReview-Commit-ID: CS1q6LyUsIe
media/mtransport/nriceresolver.cpp
media/mtransport/nriceresolver.h
--- a/media/mtransport/nriceresolver.cpp
+++ b/media/mtransport/nriceresolver.cpp
@@ -194,42 +194,43 @@ abort:
   return _status;
 }
 
 nsresult NrIceResolver::PendingResolution::OnLookupComplete(
     nsICancelable *request, nsIDNSRecord *record, nsresult status) {
   ASSERT_ON_THREAD(thread_);
   // First check if we've been canceled. This is single-threaded on the STS
   // thread, but cancel() cannot guarantee this event isn't on the queue.
-  if (!canceled_) {
+  if (request_) {
     nr_transport_addr *cb_addr = nullptr;
     nr_transport_addr ta;
     // TODO(jib@mozilla.com): Revisit when we do TURN.
     if (NS_SUCCEEDED(status)) {
       net::NetAddr na;
       if (NS_SUCCEEDED(record->GetNextAddr(port_, &na))) {
         MOZ_ALWAYS_TRUE (nr_netaddr_to_transport_addr(&na, &ta,
                                                       transport_) == 0);
         cb_addr = &ta;
       }
     }
     cb_(cb_arg_, cb_addr);
+    request_ = nullptr;
     Release();
   }
   return NS_OK;
 }
 
 int NrIceResolver::cancel(void *obj, void *handle) {
   MOZ_ALWAYS_TRUE(obj);
   MOZ_ASSERT(handle);
   ASSERT_ON_THREAD(static_cast<NrIceResolver *>(obj)->sts_thread_);
   return static_cast<PendingResolution *>(handle)->cancel();
 }
 
 int NrIceResolver::PendingResolution::cancel() {
   request_->Cancel (NS_ERROR_ABORT);
-  canceled_ = true; // in case OnLookupComplete is already on event queue.
+  request_ = nullptr;
   Release();
   return 0;
 }
 
 NS_IMPL_ISUPPORTS(NrIceResolver::PendingResolution, nsIDNSListener);
 }  // End of namespace mozilla
--- a/media/mtransport/nriceresolver.h
+++ b/media/mtransport/nriceresolver.h
@@ -90,32 +90,30 @@ class NrIceResolver
     PendingResolution(nsIEventTarget *thread,
                       uint16_t port,
                       int transport,
                       int (*cb)(void *cb_arg, nr_transport_addr *addr),
                       void *cb_arg) :
         thread_(thread),
         port_(port),
         transport_(transport),
-        cb_(cb), cb_arg_(cb_arg),
-        canceled_ (false) {}
+        cb_(cb), cb_arg_(cb_arg) {}
     NS_IMETHOD OnLookupComplete(nsICancelable *request, nsIDNSRecord *record,
                                 nsresult status) override;
     int cancel();
     nsCOMPtr<nsICancelable> request_;
     NS_DECL_THREADSAFE_ISUPPORTS
 
    private:
     virtual ~PendingResolution(){};
     nsCOMPtr<nsIEventTarget> thread_;
     uint16_t port_;
     int transport_;
     int (*cb_)(void *cb_arg, nr_transport_addr *addr);
     void *cb_arg_;
-    bool canceled_;
   };
 
   nr_resolver_vtbl* vtbl_;
   nsCOMPtr<nsIEventTarget> sts_thread_;
   nsCOMPtr<nsIDNSService> dns_;
 #ifdef DEBUG
   int allocated_resolvers_;
 #endif