From 709d51f4854bd87f5505bf02153e67c3cc276c9c Mon Sep 17 00:00:00 2001 From: Olivier Dion <olivier.dion@savoirfairelinux.com> Date: Fri, 19 Nov 2021 10:57:07 -0500 Subject: [PATCH] ice_transport: Replace assertion for conditional Change-Id: Ieb12a81646de61bce2cbb1e369e1c8a82ea118da --- src/ice_transport.cpp | 54 +++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/src/ice_transport.cpp b/src/ice_transport.cpp index 3abf63d6ad..912b4171c3 100644 --- a/src/ice_transport.cpp +++ b/src/ice_transport.cpp @@ -322,41 +322,45 @@ IceTransport::Impl::~Impl() thread_.join(); } - pj_ice_strans* strans = nullptr; + if (icest_) { - std::swap(strans, icest_); + pj_ice_strans* strans = nullptr; - assert(strans); + std::swap(strans, icest_); - // must be done before ioqueue/timer destruction - JAMI_INFO("[ice:%p] Destroying ice_strans %p", pj_ice_strans_get_user_data(strans), strans); + // must be done before ioqueue/timer destruction + JAMI_INFO("[ice:%p] Destroying ice_strans %p", + pj_ice_strans_get_user_data(strans), strans); - pj_ice_strans_stop_ice(strans); - pj_ice_strans_destroy(strans); + pj_ice_strans_stop_ice(strans); + pj_ice_strans_destroy(strans); - // NOTE: This last timer heap and IO queue polling is necessary to close - // TURN socket. - // Because when destroying the TURN session pjproject creates a pj_timer - // to postpone the TURN destruction. This timer is only called if we poll - // the event queue. + // NOTE: This last timer heap and IO queue polling is necessary to close + // TURN socket. + // Because when destroying the TURN session pjproject creates a pj_timer + // to postpone the TURN destruction. This timer is only called if we poll + // the event queue. - int ret = flushTimerHeapAndIoQueue(); + int ret = flushTimerHeapAndIoQueue(); - if (ret < 0) { - JAMI_ERR("[ice:%p] IO queue polling failed", this); - } else if (ret > 0) { - JAMI_ERR("[ice:%p] Unexpected left timer in timer heap. Please report the bug", this); - } + if (ret < 0) { + JAMI_ERR("[ice:%p] IO queue polling failed", this); + } else if (ret > 0) { + JAMI_ERR("[ice:%p] Unexpected left timer in timer heap. " + "Please report the bug", + this); + } - if (checkEventQueue(1) > 0) { - JAMI_WARN("[ice:%p] Unexpected left events in IO queue", this); - } + if (checkEventQueue(1) > 0) { + JAMI_WARN("[ice:%p] Unexpected left events in IO queue", this); + } - if (config_.stun_cfg.ioqueue) - pj_ioqueue_destroy(config_.stun_cfg.ioqueue); + if (config_.stun_cfg.ioqueue) + pj_ioqueue_destroy(config_.stun_cfg.ioqueue); - if (config_.stun_cfg.timer_heap) - pj_timer_heap_destroy(config_.stun_cfg.timer_heap); + if (config_.stun_cfg.timer_heap) + pj_timer_heap_destroy(config_.stun_cfg.timer_heap); + } JAMI_DBG("[ice:%p] done destroying", this); } -- GitLab