Skip to content

Commit

Permalink
sip: try to resolve sips transport living scope
Browse files Browse the repository at this point in the history
This patch tries to decrease some refcount on share_ptr<SipTransport>
to not lock them all the time.

Tuleap: #64
Change-Id: Ibbdf91bfd7e978fe2f04693130cd77d8937b8fab
  • Loading branch information
Guillaume Roguez authored and Alexandre Lision committed Apr 6, 2016
1 parent ac9dcfa commit 0abf627
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 4 additions & 7 deletions src/sip/sipcall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand All @@ -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);
}
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/sip/sipcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0abf627

Please sign in to comment.