diff --git a/src/ice_transport.cpp b/src/ice_transport.cpp index e7a7238f41d212f49e081cd517e53e13a1b0a1ce..9906b028d502bfc734f54356a2ad8a8b548257a3 100644 --- a/src/ice_transport.cpp +++ b/src/ice_transport.cpp @@ -296,7 +296,6 @@ add_turn_server(pj_pool_t& pool, pj_ice_strans_cfg& cfg, const TurnServerInfo& i IceTransport::Impl::Impl(const char* name, const IceTransportOptions& options) : pool_(nullptr, [](pj_pool_t* pool) { - sip_utils::register_thread(); pj_pool_release(pool); }) , on_initdone_cb_(options.onInitDone) @@ -318,7 +317,6 @@ IceTransport::Impl::Impl(const char* name, const IceTransportOptions& options) compCount_, initiatorSession_ ? "master" : "slave"); - sip_utils::register_thread(); if (options.upnpEnable) upnp_.reset(new upnp::Controller()); @@ -441,7 +439,6 @@ IceTransport::Impl::Impl(const char* name, const IceTransportOptions& options) // Must be created after any potential failure thread_ = std::thread([this] { - sip_utils::register_thread(); while (not threadTerminateFlags_) { // NOTE: handleEvents can return false in this case // but here we don't care if there is event or not. @@ -457,7 +454,6 @@ IceTransport::Impl::~Impl() { JAMI_DBG("[ice:%p] destroying %p", this, icest_); - sip_utils::register_thread(); threadTerminateFlags_ = true; iceCV_.notify_all(); @@ -1127,7 +1123,6 @@ IceTransport::isInitiator() const bool IceTransport::startIce(const Attribute& rem_attrs, std::vector<IceCandidate>&& rem_candidates) { - sip_utils::register_thread(); if (not isInitialized()) { JAMI_ERR("[ice:%p] not initialized transport", pimpl_.get()); @@ -1202,7 +1197,6 @@ IceTransport::startIce(const Attribute& rem_attrs, std::vector<IceCandidate>&& r bool IceTransport::startIce(const SDP& sdp) { - sip_utils::register_thread(); if (pimpl_->streamsCount_ != 1) { JAMI_ERR("Expected exactly one stream per SDP (found %u streams)", pimpl_->streamsCount_); @@ -1598,7 +1592,6 @@ IceTransport::send(unsigned compId, const unsigned char* buf, size_t len) { ASSERT_COMP_ID(compId, getComponentCount()); - sip_utils::register_thread(); auto remote = getRemoteAddress(compId); if (!remote) { @@ -1769,7 +1762,6 @@ IceTransportFactory::IceTransportFactory() }) , ice_cfg_() { - sip_utils::register_thread(); pj_caching_pool_init(cp_.get(), NULL, 0); diff --git a/src/jamidht/channeled_transport.cpp b/src/jamidht/channeled_transport.cpp index 33686919d9a2d6c4af2878252a521832a50e84b9..fe2dd4065c5b469de9a5ad23b3f80395a62019ed 100644 --- a/src/jamidht/channeled_transport.cpp +++ b/src/jamidht/channeled_transport.cpp @@ -227,7 +227,6 @@ ChanneledSIPTransport::handleEvents() rxPending_.clear(); } - sip_utils::register_thread(); for (auto it = rx.begin(); it != rx.end(); ++it) { auto& pck = *it; pj_pool_reset(rdata_.tp_info.pool); diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index 81fc87505113d0ca29c545566d96069dfe222642..169c03274142540ac2d89829abaca15d21ed1ff7 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -3293,7 +3293,6 @@ JamiAccount::sendTextMessage(const std::string& to, std::shared_ptr<std::set<DeviceId>> devices = std::make_shared<std::set<DeviceId>>(); std::unique_lock<std::mutex> lk(sipConnsMtx_); - sip_utils::register_thread(); for (auto it = sipConns_.begin(); it != sipConns_.end();) { auto& [key, value] = *it; @@ -4842,7 +4841,6 @@ JamiAccount::sendSIPMessage(SipConnection& conn, auto shared = w.lock(); if (!shared) return; - sip_utils::register_thread(); auto status = pjsip_endpt_send_request(shared->link_.getEndpoint(), tdata, -1, ctx, cb); if (status != PJ_SUCCESS) JAMI_ERR("Unable to send request: %s", sip_utils::sip_strerror(status).c_str()); @@ -4900,7 +4898,6 @@ JamiAccount::cacheSIPConnection(std::shared_ptr<ChannelSocket>&& socket, } // Convert to SIP transport - sip_utils::register_thread(); auto onShutdown = [w = weak(), peerId, key, socket]() { auto shared = w.lock(); if (!shared) diff --git a/src/sip/sdp.cpp b/src/sip/sdp.cpp index c11c62eb6f1bffb5c93c96f1c182271f39179b2a..51d7a505b003f1b632689d0431f7269fd7820d62 100644 --- a/src/sip/sdp.cpp +++ b/src/sip/sdp.cpp @@ -59,7 +59,6 @@ static constexpr int POOL_INCREMENT_SIZE = POOL_INITIAL_SIZE; Sdp::Sdp(const std::string& id) : memPool_(nullptr, [](pj_pool_t* pool) { - sip_utils::register_thread(); pj_pool_release(pool); }) , publishedIpAddr_() @@ -67,7 +66,6 @@ Sdp::Sdp(const std::string& id) , telephoneEventPayload_(101) // same as asterisk , sessionName_("Call ID " + id) { - sip_utils::register_thread(); memPool_.reset(pj_pool_create(&Manager::instance().sipVoIPLink().getCachingPool()->factory, id.c_str(), POOL_INITIAL_SIZE, @@ -456,7 +454,6 @@ void Sdp::printSession(const pjmedia_sdp_session* session, const char* header, SdpDirection direction) { static constexpr size_t BUF_SZ = 4095; - sip_utils::register_thread(); std::unique_ptr<pj_pool_t, decltype(pj_pool_release)&> tmpPool_(pj_pool_create(&Manager::instance().sipVoIPLink().getCachingPool()->factory, "printSdp", @@ -674,7 +671,6 @@ Sdp::startNegotiation() std::string Sdp::getFilteredSdp(const pjmedia_sdp_session* session, unsigned media_keep, unsigned pt_keep) { - sip_utils::register_thread(); static constexpr size_t BUF_SZ = 4096; std::unique_ptr<pj_pool_t, decltype(pj_pool_release)&> tmpPool_(pj_pool_create(&Manager::instance().sipVoIPLink().getCachingPool()->factory, diff --git a/src/sip/sip_utils.cpp b/src/sip/sip_utils.cpp index 39a8e26b7c2580a0ed0da20baa25c3b3ebc7fd7c..5821bd346be9841979879fbcad2eda7bcaa6186f 100644 --- a/src/sip/sip_utils.cpp +++ b/src/sip/sip_utils.cpp @@ -257,22 +257,6 @@ sip_strerror(pj_status_t code) return std::string {ret.ptr, ret.ptr + ret.slen}; } -void -register_thread() -{ - if (!pj_thread_is_registered()) { -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || defined _MSC_VER - static thread_local pj_thread_desc desc; - static thread_local pj_thread_t* this_thread; -#else - static __thread pj_thread_desc desc; - static __thread pj_thread_t* this_thread; -#endif - pj_thread_register(NULL, desc, &this_thread); - JAMI_DBG("Registered thread %p (0x%X)", this_thread, pj_getpid()); - } -} - void sockaddr_to_host_port(pj_pool_t* pool, pjsip_host_port* host_port, const pj_sockaddr* addr) { diff --git a/src/sip/sip_utils.h b/src/sip/sip_utils.h index 0e8e59da30ee8b622b26c73feb04ae9e025047c3..31e58ca793e943460621f5eca1fec1d3fd77dca7 100644 --- a/src/sip/sip_utils.h +++ b/src/sip/sip_utils.h @@ -103,12 +103,6 @@ void logMessageHeaders(const pjsip_hdr* hdr_list); std::string sip_strerror(pj_status_t code); -/// \brief PJSIP requires to register all threads that access to its API. -/// -/// This function is safe to be called multiple time by same thread, -/// it will be registered only one time. -void register_thread(); - // Helper function that return a constant pj_str_t from an array of any types // that may be statically casted into char pointer. // Per convention, the input array is supposed to be null terminated. diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp index dbe80b4dee7488b5669daac32ddb4f186117cce5..57d03bbb6b0aff636be934bc574b795c49c12701 100644 --- a/src/sip/sipaccount.cpp +++ b/src/sip/sipaccount.cpp @@ -2182,7 +2182,6 @@ SIPAccount::sendTextMessage(const std::string& to, return; } - sip_utils::register_thread(); auto toUri = getToUri(to); diff --git a/src/sip/sipvoiplink.cpp b/src/sip/sipvoiplink.cpp index 7c534838988c1d3ef0550aa0d83be143d714b8d9..fc246189617ef4e4518c6096825cba6322867d90 100644 --- a/src/sip/sipvoiplink.cpp +++ b/src/sip/sipvoiplink.cpp @@ -635,7 +635,6 @@ SIPVoIPLink::SIPVoIPLink() throw VoipLinkException(#ret " failed"); \ } while (0) - sip_utils::register_thread(); pj_caching_pool_init(&cp_, &pj_pool_factory_default_policy, 0); pool_.reset(pj_pool_create(&cp_.factory, PACKAGE, 64 * 1024, 4096, nullptr)); if (!pool_) @@ -748,7 +747,6 @@ SIPVoIPLink::SIPVoIPLink() #undef TRY sipThread_ = std::thread([this] { - sip_utils::register_thread(); while (running_) handleEvents(); });