Skip to content
Snippets Groups Projects
Commit 0abf627b authored by Guillaume Roguez's avatar Guillaume Roguez Committed by Alexandre Lision
Browse files

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
parent ac9dcfad
No related branches found
No related tags found
No related merge requests found
...@@ -183,7 +183,7 @@ void SIPCall::setContactHeader(pj_str_t *contact) ...@@ -183,7 +183,7 @@ void SIPCall::setContactHeader(pj_str_t *contact)
} }
void 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); const auto list_id = reinterpret_cast<uintptr_t>(this);
if (transport_) if (transport_)
...@@ -195,18 +195,15 @@ SIPCall::setTransport(const std::shared_ptr<SipTransport>& t) ...@@ -195,18 +195,15 @@ SIPCall::setTransport(const std::shared_ptr<SipTransport>& t)
// listen for transport destruction // listen for transport destruction
transport_->addStateListener(list_id, transport_->addStateListener(list_id,
[wthis_, t, list_id] (pjsip_transport_state state, [wthis_] (pjsip_transport_state state, const pjsip_transport_state_info*) {
const pjsip_transport_state_info*)
{
if (auto this_ = wthis_.lock()) { if (auto this_ = wthis_.lock()) {
// end the call if the SIP transport is shut down // 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", RING_WARN("[call:%s] Ending call because underlying SIP transport was closed",
this_->getCallId().c_str()); this_->getCallId().c_str());
this_->onFailure(ECONNRESET); this_->onFailure(ECONNRESET);
} }
} else // should not happen }
t->removeStateListener(list_id);
}); });
} }
} }
......
...@@ -128,10 +128,10 @@ class SIPCall : public Call ...@@ -128,10 +128,10 @@ class SIPCall : public Call
void setContactHeader(pj_str_t *contact); 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() { inline SipTransport* getTransport() {
return transport_; return transport_.get();
} }
void sendSIPInfo(const char *const body, const char *const subtype); void sendSIPInfo(const char *const body, const char *const subtype);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment