Commit 08cb82bc authored by Guillaume Roguez's avatar Guillaume Roguez
Browse files

sip: fix SIPVoIPLink destructor

Reordering implementation of SIPVoIPLink destructor.
This fix dependencies issues.

Refs #64903

Change-Id: I4f96359bd0708f79592bac325150edf7b149f843
parent 0b6192b3
......@@ -499,8 +499,6 @@ pj_pool_t* SIPVoIPLink::getPool() const
SIPVoIPLink::SIPVoIPLink()
{
RING_DBG("creating SIPVoIPLink instance");
#define TRY(ret) do { \
if (ret != PJ_SUCCESS) \
throw VoipLinkException(#ret " failed"); \
......@@ -598,36 +596,40 @@ SIPVoIPLink::SIPVoIPLink()
// as handleEvents needs a valid instance to be called.
Manager::instance().registerEventHandler((uintptr_t)this,
[this]{ handleEvents(); });
RING_DBG("SIPVoIPLink@%p", this);
}
SIPVoIPLink::~SIPVoIPLink()
{
RING_DBG("destroying SIPVoIPLink instance");
RING_DBG("~SIPVoIPLink@%p", this);
const int MAX_TIMEOUT_ON_LEAVING = 5;
// Remaining calls should not happen as possible upper callbacks
// may be called and another instance of SIPVoIPLink can be re-created!
if (not Manager::instance().callFactory.empty<SIPCall>())
RING_ERR("%d SIP calls remains!",
Manager::instance().callFactory.callCount<SIPCall>());
sipTransportBroker->shutdown();
for (int timeout = 0; pjsip_tsx_layer_get_tsx_count() and timeout < MAX_TIMEOUT_ON_LEAVING; timeout++)
const int MAX_TIMEOUT_ON_LEAVING = 5;
for (int timeout = 0;
pjsip_tsx_layer_get_tsx_count() and timeout < MAX_TIMEOUT_ON_LEAVING;
timeout++)
sleep(1);
const pj_time_val tv = {0, 10};
pjsip_endpt_handle_events(endpt_, &tv);
if (!Manager::instance().callFactory.empty<SIPCall>())
RING_ERR("%d SIP calls remains!",
Manager::instance().callFactory.callCount<SIPCall>());
pjsip_tpmgr_set_state_cb(pjsip_endpt_get_tpmgr(endpt_), nullptr);
Manager::instance().unregisterEventHandler((uintptr_t)this);
handleEvents();
// destroy SIP transport before endpoint
sipTransportBroker.reset();
Manager::instance().unregisterEventHandler((uintptr_t)this);
pjsip_endpt_destroy(endpt_);
pj_pool_release(pool_);
pj_caching_pool_destroy(cp_);
RING_DBG("destroying SIPVoIPLink@%p", this);
}
std::shared_ptr<SIPAccountBase>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment