Bug 1054908 - Ensure socket_child_ is released on main thread. r=mt
authorShih-Chiang Chien <schien@mozilla.com>
Mon, 18 Aug 2014 19:14:00 -0400
changeset 200266 2ec59bdec08879b5c2cfd0ab50f6e62cfdb12d7a
parent 200265 8944f233d14b0863b90ec4e6800a0735bd7cafba
child 200267 bb91698edd20cc16dbd3613105bcaa9f19b4b71a
push id47860
push userryanvm@gmail.com
push dateTue, 19 Aug 2014 12:42:37 +0000
treeherdermozilla-inbound@bb91698edd20 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmt
bugs1054908
milestone34.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 1054908 - Ensure socket_child_ is released on main thread. r=mt
media/mtransport/nr_socket_prsock.cpp
media/mtransport/nr_socket_prsock.h
--- a/media/mtransport/nr_socket_prsock.cpp
+++ b/media/mtransport/nr_socket_prsock.cpp
@@ -1021,22 +1021,23 @@ int NrSocketIpc::read(void* buf, size_t 
 
 // Main thread executors
 void NrSocketIpc::create_m(const nsACString &host, const uint16_t port) {
   ASSERT_ON_THREAD(main_thread_);
 
   ReentrantMonitorAutoEnter mon(monitor_);
 
   nsresult rv;
-  socket_child_ = do_CreateInstance("@mozilla.org/udp-socket-child;1", &rv);
+  nsCOMPtr<nsIUDPSocketChild> socketChild = do_CreateInstance("@mozilla.org/udp-socket-child;1", &rv);
   if (NS_FAILED(rv)) {
     err_ = true;
     MOZ_ASSERT(false, "Failed to create UDPSocketChild");
   }
 
+  socket_child_ = new nsMainThreadPtrHolder<nsIUDPSocketChild>(socketChild);
   socket_child_->SetFilterName(nsCString("stun"));
 
   if (NS_FAILED(socket_child_->Bind(this, host, port))) {
     err_ = true;
     MOZ_ASSERT(false, "Failed to create UDP socket");
   }
 }
 
--- a/media/mtransport/nr_socket_prsock.h
+++ b/media/mtransport/nr_socket_prsock.h
@@ -53,16 +53,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsASocketHandler.h"
 #include "nsISocketTransportService.h"
 #include "nsXPCOM.h"
 #include "nsIEventTarget.h"
 #include "nsIUDPSocketChild.h"
+#include "nsProxyRelease.h"
 
 #include "databuffer.h"
 #include "m_cpp_utils.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/TimeStamp.h"
 
 // Stub declaration for nICEr type
@@ -228,17 +229,17 @@ private:
   void close_m();
   // STS thread executor
   void recv_callback_s(RefPtr<nr_udp_message> msg);
 
   bool err_;
   NrSocketIpcState state_;
   std::queue<RefPtr<nr_udp_message> > received_msgs_;
 
-  nsCOMPtr<nsIUDPSocketChild> socket_child_;
+  nsMainThreadPtrHandle<nsIUDPSocketChild> socket_child_;
   nsCOMPtr<nsIEventTarget> sts_thread_;
   const nsCOMPtr<nsIEventTarget> main_thread_;
   ReentrantMonitor monitor_;
 };
 
 int nr_netaddr_to_transport_addr(const net::NetAddr *netaddr,
                                  nr_transport_addr *addr,
                                  int protocol);