Skip to content

Commit

Permalink
additional msg memory leak fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
davehorton committed Nov 27, 2016
1 parent 0b2534c commit d94a331
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/sip-dialog-controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ namespace drachtio {
"ACK for non-success responses is automatically generated by the stack" ) ;
}
else {
msg_t* m = nta_outgoing_getrequest(orq) ;
msg_t* m = nta_outgoing_getrequest(orq) ; // adds a reference
sip_t* sip = sip_object( m ) ;

if( sip_method_ack == method ) {
Expand All @@ -259,6 +259,7 @@ namespace drachtio {
string s ;
meta.toMessageFormat(s) ;
string data = s + "|" + pData->getTransactionId() + "|Msg sent:|" + CRLF + encodedMessage ;
msg_destroy(m) ; //releases reference

m_pController->getClientController()->route_api_response( pData->getClientMsgId(), "OK", data ) ;
}
Expand Down Expand Up @@ -395,7 +396,7 @@ namespace drachtio {
throw std::runtime_error("Error creating sip transaction for uac request") ;
}

msg_t* m = nta_outgoing_getrequest(orq) ;
msg_t* m = nta_outgoing_getrequest(orq) ; //adds a reference
sip_t* sip = sip_object( m ) ;

if( method == sip_method_invite ) {
Expand All @@ -414,6 +415,7 @@ namespace drachtio {
SipMsgData_t meta(m, orq) ;
string s ;
meta.toMessageFormat(s) ;
msg_destroy(m) ; // releases reference

string data = s + "|" + pData->getTransactionId() + "|Msg sent:|" + CRLF + encodedMessage ;

Expand Down Expand Up @@ -474,7 +476,7 @@ namespace drachtio {
if( findIIPByTransactionId( transactionId, iip ) ) {
nta_outgoing_t *cancel = nta_outgoing_tcancel(iip->orq(), NULL, NULL, TAG_NULL());
if( NULL != cancel ) {
msg_t* m = nta_outgoing_getrequest(cancel) ;
msg_t* m = nta_outgoing_getrequest(cancel) ; // adds a reference
sip_t* sip = sip_object( m ) ;

string cancelTransactionId ;
Expand All @@ -486,6 +488,7 @@ namespace drachtio {
string s ;
meta.toMessageFormat(s) ;
string data = s + "|" + cancelTransactionId + "|Msg sent:|" + CRLF + encodedMessage ;
msg_destroy(m) ;

//Note: not adding an RIP because the 200 OK to the CANCEL is not passed up to us
//boost::shared_ptr<RIP> p = boost::make_shared<RIP>( cancelTransactionId, iip->dlg() ? iip->dlg()->getDialogId() : "" ) ;
Expand Down Expand Up @@ -573,8 +576,9 @@ namespace drachtio {

string encodedMessage ;
bool truncated ;
msg_t* msg = nta_outgoing_getresponse(orq) ;
msg_t* msg = nta_outgoing_getresponse(orq) ; //adds a reference
SipMsgData_t meta( msg, orq, "network") ;
msg_destroy( msg ) ; //releases reference

EncodeStackMessage( sip, encodedMessage ) ;

Expand Down Expand Up @@ -904,10 +908,11 @@ namespace drachtio {

string encodedMessage ;
bool truncated ;
msg_t* msg = nta_outgoing_getresponse(orq) ;
msg_t* msg = nta_outgoing_getresponse(orq) ; // adds a reference
SipMsgData_t meta( msg, orq, "network") ;

EncodeStackMessage( sip, encodedMessage ) ;
msg_destroy(msg) ; // releases reference

m_pController->getClientController()->route_response_inside_transaction( encodedMessage, meta, orq, sip, rip->getTransactionId(), rip->getDialogId() ) ;

Expand Down Expand Up @@ -995,9 +1000,10 @@ namespace drachtio {
DR_LOG(log_debug) << "SipDialogController::processCancelOrAck - Received CANCEL for call-id " << sip->sip_call_id->i_id << ", sending to client" ;

string encodedMessage ;
msg_t* msg = nta_incoming_getrequest( irq ) ;
msg_t* msg = nta_incoming_getrequest( irq ) ; // adds a reference
EncodeStackMessage( sip, encodedMessage ) ;
SipMsgData_t meta( msg, irq ) ;
msg_destroy(msg); // releases reference

m_pClientController->route_request_inside_invite( encodedMessage, meta, irq, sip, iip->getTransactionId(), dlg->getDialogId() ) ;

Expand Down Expand Up @@ -1047,9 +1053,10 @@ namespace drachtio {
m_pClientController->addDialogForTransaction( dlg->getTransactionId(), dlg->getDialogId() ) ;

string encodedMessage ;
msg_t* msg = nta_incoming_getrequest( prack ) ;
msg_t* msg = nta_incoming_getrequest( prack ) ; // adds a reference
EncodeStackMessage( sip, encodedMessage ) ;
SipMsgData_t meta( msg, prack ) ;
msg_destroy(msg); // releases the reference

m_pClientController->route_request_inside_dialog( encodedMessage, meta, prack, sip, transactionId, dlg->getDialogId() ) ;

Expand Down

0 comments on commit d94a331

Please sign in to comment.