Bug 1279146 - Clean up streams on shutdown. r=bwc, a=lizzard
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Thu, 07 Jul 2016 21:33:23 -0400
changeset 339906 496264b64d722c9e8c6713d4244536b258979c16
parent 339905 193762e3a279d424023b85b0ac86f9bb0e0e1687
child 339907 632484723c99dc0ac9dcf11e25ec10e8fdb8dabf
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc, lizzard
bugs1279146
milestone49.0a2
Bug 1279146 - Clean up streams on shutdown. r=bwc, a=lizzard
media/mtransport/nricectx.cpp
media/mtransport/nricemediastream.cpp
media/mtransport/transportlayerdtls.cpp
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -666,16 +666,21 @@ void NrIceCtx::internal_DeinitializeGlob
 }
 
 void NrIceCtx::internal_SetTimerAccelarator(int divider) {
   ctx_->test_timer_divider = divider;
 }
 
 NrIceCtx::~NrIceCtx() {
   MOZ_MTLOG(ML_DEBUG, "Destroying ICE ctx '" << name_ <<"'");
+  for (auto stream = streams_.begin(); stream != streams_.end(); stream++) {
+    if (*stream) {
+      (*stream)->Close();
+    }
+  }
   nr_ice_peer_ctx_destroy(&peer_);
   nr_ice_ctx_destroy(&ctx_);
   delete ice_handler_vtbl_;
   delete ice_handler_;
 }
 
 void
 NrIceCtx::SetStream(size_t index, NrIceMediaStream* stream) {
--- a/media/mtransport/nricemediastream.cpp
+++ b/media/mtransport/nricemediastream.cpp
@@ -593,15 +593,18 @@ void NrIceMediaStream::Ready() {
     MOZ_MTLOG(ML_DEBUG, "Stream ready callback fired again for '" << name_ << "'");
   }
 }
 
 void NrIceMediaStream::Close() {
   MOZ_MTLOG(ML_DEBUG, "Marking stream closed '" << name_ << "'");
   state_ = ICE_CLOSED;
 
-  int r = nr_ice_remove_media_stream(ctx_, &stream_);
-  if (r) {
-    MOZ_ASSERT(false, "Failed to remove stream");
-    MOZ_MTLOG(ML_ERROR, "Failed to remove stream, error=" << r);
+  if (stream_) {
+    int r = nr_ice_remove_media_stream(ctx_, &stream_);
+    if (r) {
+      MOZ_ASSERT(false, "Failed to remove stream");
+      MOZ_MTLOG(ML_ERROR, "Failed to remove stream, error=" << r);
+    }
   }
 }
+
 }  // close namespace
--- a/media/mtransport/transportlayerdtls.cpp
+++ b/media/mtransport/transportlayerdtls.cpp
@@ -363,16 +363,17 @@ static const struct PRIOMethods Transpor
   TransportLayerConnectContinue,
   TransportLayerReserved,
   TransportLayerReserved,
   TransportLayerReserved,
   TransportLayerReserved
 };
 
 TransportLayerDtls::~TransportLayerDtls() {
+  nspr_io_adapter_->SetEnabled(false);
   if (timer_) {
     timer_->Cancel();
   }
 }
 
 nsresult TransportLayerDtls::InitInternal() {
   // Get the transport service as an event target
   nsresult rv;