From cf72929a61d6f515ec48d0f82884601ad0c0fa6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Mon, 6 Aug 2018 17:39:40 -0400 Subject: [PATCH] sips/ice: use ScheduledExecutor Change-Id: I1fc4a0a68446911aaee0102d7ddca4c0d5c6980e --- src/ringdht/sips_transport_ice.cpp | 6 +++--- src/ringdht/sips_transport_ice.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ringdht/sips_transport_ice.cpp b/src/ringdht/sips_transport_ice.cpp index 3f993d9cfb..3356efed44 100644 --- a/src/ringdht/sips_transport_ice.cpp +++ b/src/ringdht/sips_transport_ice.cpp @@ -249,8 +249,6 @@ SipsIceTransport::SipsIceTransport(pjsip_endpoint* endpt, if (pjsip_transport_register(base.tpmgr, &base) != PJ_SUCCESS) throw std::runtime_error("Can't register PJSIP transport."); - - Manager::instance().registerEventHandler((uintptr_t)this, [this]{ handleEvents(); }); } SipsIceTransport::~SipsIceTransport() @@ -266,7 +264,6 @@ SipsIceTransport::~SipsIceTransport() } auto base = getTransportBase(); - Manager::instance().unregisterEventHandler((uintptr_t)this); // Stop low-level transport first tls_.reset(); @@ -394,6 +391,7 @@ SipsIceTransport::pushChangeStateEvent(ChangeStateEventData&& ev) { std::lock_guard<std::mutex> lk{stateChangeEventsMutex_}; stateChangeEvents_.emplace_back(std::move(ev)); + scheduler_.run([this]{ handleEvents(); }); } // - DO NOT BLOCK - (Called in TlsSession thread) @@ -412,6 +410,7 @@ SipsIceTransport::onRxData(std::vector<uint8_t>&& buf) { std::lock_guard<std::mutex> l(rxMtx_); rxPending_.emplace_back(std::move(buf)); + scheduler_.run([this]{ handleEvents(); }); } /* Update local & remote certificates info. This function should be @@ -698,6 +697,7 @@ SipsIceTransport::send(pjsip_tx_data* tdata, const pj_sockaddr_t* rem_addr, tdata->op_key.token = token; tdata->op_key.callback = callback; txQueue_.push_back(tdata); + scheduler_.run([this]{ handleEvents(); }); return PJ_EPENDING; } diff --git a/src/ringdht/sips_transport_ice.h b/src/ringdht/sips_transport_ice.h index bcbb368db7..74e9283e4a 100644 --- a/src/ringdht/sips_transport_ice.h +++ b/src/ringdht/sips_transport_ice.h @@ -24,6 +24,7 @@ #include "security/tls_session.h" #include "ip_utils.h" #include "noncopyable.h" +#include "scheduled_executor.h" #include <pjsip.h> #include <pj/pool.h> @@ -124,6 +125,8 @@ private: std::mutex rxMtx_; std::list<std::vector<uint8_t>> rxPending_; + ScheduledExecutor scheduler_; + pj_status_t send(pjsip_tx_data*, const pj_sockaddr_t*, int, void*, pjsip_transport_callback); void handleEvents(); void pushChangeStateEvent(ChangeStateEventData&&); -- GitLab