From 0abf627b3bd3806c98f55bfc407504aa5e6e94c2 Mon Sep 17 00:00:00 2001 From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> Date: Wed, 27 Jan 2016 15:12:24 -0500 Subject: [PATCH] sip: try to resolve sips transport living scope This patch tries to decrease some refcount on share_ptr<SipTransport> to not lock them all the time. Tuleap: #64 Change-Id: Ibbdf91bfd7e978fe2f04693130cd77d8937b8fab --- src/sip/sipcall.cpp | 11 ++++------- src/sip/sipcall.h | 6 +++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp index 53ab650af0..df972e9730 100644 --- a/src/sip/sipcall.cpp +++ b/src/sip/sipcall.cpp @@ -183,7 +183,7 @@ void SIPCall::setContactHeader(pj_str_t *contact) } void -SIPCall::setTransport(const std::shared_ptr<SipTransport>& t) +SIPCall::setTransport(std::shared_ptr<SipTransport> t) { const auto list_id = reinterpret_cast<uintptr_t>(this); if (transport_) @@ -195,18 +195,15 @@ SIPCall::setTransport(const std::shared_ptr<SipTransport>& t) // listen for transport destruction transport_->addStateListener(list_id, - [wthis_, t, list_id] (pjsip_transport_state state, - const pjsip_transport_state_info*) - { + [wthis_] (pjsip_transport_state state, const pjsip_transport_state_info*) { if (auto this_ = wthis_.lock()) { // end the call if the SIP transport is shut down - if (not SipTransport::isAlive(t, state) and this_->getConnectionState() != ConnectionState::DISCONNECTED) { + if (not SipTransport::isAlive(this_->transport_, state) and this_->getConnectionState() != ConnectionState::DISCONNECTED) { RING_WARN("[call:%s] Ending call because underlying SIP transport was closed", this_->getCallId().c_str()); this_->onFailure(ECONNRESET); } - } else // should not happen - t->removeStateListener(list_id); + } }); } } diff --git a/src/sip/sipcall.h b/src/sip/sipcall.h index 2d70dbfb47..4c252066bb 100644 --- a/src/sip/sipcall.h +++ b/src/sip/sipcall.h @@ -128,10 +128,10 @@ class SIPCall : public Call void setContactHeader(pj_str_t *contact); - void setTransport(const std::shared_ptr<SipTransport>& t); + void setTransport(std::shared_ptr<SipTransport> t); - inline const std::shared_ptr<SipTransport>& getTransport() { - return transport_; + inline SipTransport* getTransport() { + return transport_.get(); } void sendSIPInfo(const char *const body, const char *const subtype); -- GitLab