Bug 1279146 - Clean up streams on shutdown. r=bwc a=lizzard FIREFOX_48_0b7_BUILD1 FIREFOX_48_0b7_RELEASE
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Mon, 11 Jul 2016 09:26:25 +0200
changeset 387409 9d734024ed35d74449601cc04917b327e0973c0d
parent 387408 e0770c0fbc7b7bbcb6be3d4d063f3d4a0ffdb7a2
child 387410 7c9c052d51bb26ff6bfb2a7eae649b1b7f008e32
push id22943
push usermichael.l.comella@gmail.com
push dateWed, 13 Jul 2016 21:34:52 +0000
reviewersbwc, lizzard
bugs1279146
milestone48.0
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
@@ -661,16 +661,21 @@ void NrIceCtx::internal_DeinitializeGlob
   NR_reg_del((char *)"ice");
   RLogRingBuffer::DestroyInstance();
   nr_crypto_vtbl = nullptr;
   initialized = false;
 }
 
 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
@@ -568,15 +568,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;