Commit 0abf627b authored by Guillaume Roguez's avatar Guillaume Roguez Committed by Alexandre Lision

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
......@@ -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);
}
});
}
}
......
......@@ -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);
......
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