Skip to content

Commit

Permalink
fix for #386
Browse files Browse the repository at this point in the history
  • Loading branch information
davehorton committed Nov 21, 2024
1 parent a592b70 commit 2ce50b3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 18 deletions.
8 changes: 7 additions & 1 deletion src/request-handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,13 @@ namespace drachtio {
m_thread.swap( t ) ;
}
RequestHandler::~RequestHandler() {
curl_multi_cleanup(m_g.multi);
if (nullptr == m_g.multi) {
DR_LOG(log_error) << "RequestHandler::~RequestHandler - multi handle is null; this should only happen during shutdown";
}
else {
curl_multi_cleanup(m_g.multi);
m_g.multi = nullptr;
}
}
void RequestHandler::threadFunc() {

Expand Down
3 changes: 3 additions & 0 deletions src/sip-dialog-controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ namespace drachtio {

if( orq ) {
DR_LOG(log_info) << "SipDialogController::doSendRequestInsideDialog - created orq " << std::hex << (void *) orq << " sending " << nta_outgoing_method_name(orq) << " to " << requestUri ;
if( sip_method_invite == method ) {
dlg->addReinviteOrq(orq);
}
}
}

Expand Down
20 changes: 13 additions & 7 deletions src/sip-dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ namespace drachtio {

nta_leg_t *leg = nta_leg_by_call_id( theOneAndOnlyController->getAgent(), getCallId().c_str() );

DR_LOG(log_debug) << "SipDialog::~SipDialog - I'm holding leg " << std::hex << (void *) m_leg <<
" and retrieved leg via call-id " << (void *) leg;
DR_LOG(log_debug) << "SipDialog::~SipDialog - I'm holding leg " << std::hex << (void *) m_leg <<
" and retrieved leg via call-id " << (void *) leg;

assert( leg ) ;
if( leg ) {
Expand All @@ -214,6 +214,12 @@ namespace drachtio {
if (we_are_uac == m_type && m_orq) {
theOneAndOnlyController->getDialogController()->stopTimerD(m_orq);
}

for (nta_outgoing_t* item : m_reinvites) {
DR_LOG(log_debug) << "SipDialog::~SipDialog - I'm holding a reinvite orq " << std::hex << (void *) item;
theOneAndOnlyController->getDialogController()->stopTimerD(item);
}

/* N.B.: we only destroy the orq here for ACK for non-udp transports, since timer D handles for udp */
if (m_orqAck && m_bDestroyAckOnClose) {
DR_LOG(log_debug) << "SipDialog::~SipDialog - destroying orq from original (uac) ACK " << std::hex << (void *) m_orqAck ;
Expand All @@ -223,11 +229,11 @@ namespace drachtio {
nta_outgoing_destroy(m_orq);
}

auto txnIds = getIncomingRequestTransactionIds();
theOneAndOnlyController->getDialogController()->clearDanglingIncomingRequests(txnIds);
/* if we never got an ACK after sending a 200 OK to an incoming INVITE the net transaction is still there */
theOneAndOnlyController->getClientController()->removeNetTransaction(this->getTransactionId());
auto txnIds = getIncomingRequestTransactionIds();
theOneAndOnlyController->getDialogController()->clearDanglingIncomingRequests(txnIds);

/* if we never got an ACK after sending a 200 OK to an incoming INVITE the net transaction is still there */
theOneAndOnlyController->getClientController()->removeNetTransaction(this->getTransactionId());
}

std::ostream& operator<<(std::ostream& os, const SipDialog& dlg) {
Expand Down
27 changes: 17 additions & 10 deletions src/sip-dialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,19 @@ namespace drachtio {
uint32_t getSeq(void) { return m_seq; }
void clearSeq(void) {m_seq = 0;}

void addIncomingRequestTransaction(std::string& txnId) {
m_incomingRequestTransactionIds.insert(txnId);
}
void removeIncomingRequestTransaction(std::string& txnId) {
m_incomingRequestTransactionIds.erase(txnId);
}
std::vector<std::string> getIncomingRequestTransactionIds(void) {
return std::vector<std::string>(m_incomingRequestTransactionIds.begin(), m_incomingRequestTransactionIds.end());
}
void addIncomingRequestTransaction(std::string& txnId) {
m_incomingRequestTransactionIds.insert(txnId);
}
void removeIncomingRequestTransaction(std::string& txnId) {
m_incomingRequestTransactionIds.erase(txnId);
}
std::vector<std::string> getIncomingRequestTransactionIds(void) {
return std::vector<std::string>(m_incomingRequestTransactionIds.begin(), m_incomingRequestTransactionIds.end());
}

void addReinviteOrq(nta_outgoing_t* orq) {
m_reinvites.push_back(orq);
}

protected:

Expand Down Expand Up @@ -291,7 +295,10 @@ namespace drachtio {
// arrival time
sip_time_t m_tmArrival;

std::set<std::string> m_incomingRequestTransactionIds;
std::set<std::string> m_incomingRequestTransactionIds;

// re-invite orqs that we send as
std::vector<nta_outgoing_t*> m_reinvites;

} ;

Expand Down

0 comments on commit 2ce50b3

Please sign in to comment.