Bug 1293457: stop printing gathering results on shutdown. r=mjf draft
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Mon, 22 Aug 2016 00:14:59 -0700
changeset 403787 2a56762b3b6d740d9ed2a2c8d122507c00931622
parent 403581 f97a056ae6235de7855fd8aaa04fb1c8d183bd06
child 529000 54f54a7128bbedef2b413d0ee4568f4624bc8086
push id27011
push userdrno@ohlmeier.org
push dateMon, 22 Aug 2016 07:16:57 +0000
reviewersmjf
bugs1293457
milestone51.0a1
Bug 1293457: stop printing gathering results on shutdown. r=mjf MozReview-Commit-ID: LubRuNsaHBZ
media/mtransport/test/ice_unittest.cpp
--- a/media/mtransport/test/ice_unittest.cpp
+++ b/media/mtransport/test/ice_unittest.cpp
@@ -385,16 +385,17 @@ class IceTestPeer : public sigslot::has_
               bool offerer,
               bool allow_loopback = false, bool enable_tcp = true,
               bool allow_link_local = false, bool hide_non_default = false) :
       name_(name),
       ice_ctx_(NrIceCtxHandler::Create(name, offerer, allow_loopback,
                                        enable_tcp, allow_link_local,
                                        hide_non_default)),
       candidates_(),
+      shutting_down_(false),
       gathering_complete_(false),
       ready_ct_(0),
       ice_complete_(false),
       ice_reached_checking_(false),
       received_(0),
       sent_(0),
       fake_resolver_(),
       dns_resolver_(new NrIceResolver()),
@@ -965,16 +966,17 @@ class IceTestPeer : public sigslot::has_
   void Close() {
     test_utils_->sts_target()->Dispatch(
       WrapRunnable(ice_ctx_->ctx(), &NrIceCtx::destroy_peer_ctx),
       NS_DISPATCH_SYNC);
   }
 
   void Shutdown() {
     std::cerr << name_ << " Shutdown" << std::endl;
+    shutting_down_ = true;
     for (auto s = controlled_trickle_candidates_.begin();
          s != controlled_trickle_candidates_.end();
          ++s) {
       for (auto cand = s->second.begin(); cand != s->second.end(); ++cand) {
         delete *cand;
       }
     }
 
@@ -999,17 +1001,19 @@ class IceTestPeer : public sigslot::has_
         WrapRunnableRet(&res, ice_ctx_->ctx(), &NrIceCtx::StartChecks),
         NS_DISPATCH_SYNC);
     ASSERT_TRUE(NS_SUCCEEDED(res));
   }
 
   // Handle events
   void GatheringStateChange(NrIceCtx* ctx,
                             NrIceCtx::GatheringState state) {
-    (void)ctx;
+    if (shutting_down_) {
+      return;
+    }
     if (state != NrIceCtx::ICE_CTX_GATHER_COMPLETE) {
       return;
     }
 
     std::cerr << name_ << " Gathering complete" << std::endl;
     gathering_complete_ = true;
 
     std::cerr << name_ << " CANDIDATES:" << std::endl;
@@ -1394,16 +1398,17 @@ class IceTestPeer : public sigslot::has_
 
  private:
   std::string name_;
   RefPtr<NrIceCtxHandler> ice_ctx_;
   std::map<std::string, std::vector<std::string> > candidates_;
   // Maps from stream id to list of remote trickle candidates
   std::map<size_t, std::vector<SchedulableTrickleCandidate*> >
     controlled_trickle_candidates_;
+  bool shutting_down_;
   bool gathering_complete_;
   int ready_ct_;
   bool ice_complete_;
   bool ice_reached_checking_;
   size_t received_;
   size_t sent_;
   struct timeval consent_timestamp_;
   NrIceResolverFake fake_resolver_;