Commit 48fc594d authored by Simon Morlat's avatar Simon Morlat

fix transmission of CANCEL over transactions

parent 71621d36
......@@ -140,7 +140,13 @@ RequestSipEvent::RequestSipEvent(shared_ptr<IncomingAgent> incomingAgent,
SipEvent(msgSip), mRecordRouteAdded(false) {
mIncomingTport=inTport;
mIncomingAgent = incomingAgent;
mOutgoingAgent = incomingAgent->getAgent()->shared_from_this();
shared_ptr<IncomingTransaction> it=dynamic_pointer_cast<IncomingTransaction>(incomingAgent);
if (it){
mOutgoingAgent = it->mOutgoing;
}else{
mOutgoingAgent = incomingAgent->getAgent()->shared_from_this();
}
}
RequestSipEvent::RequestSipEvent(const shared_ptr<RequestSipEvent> &sipEvent) :
......@@ -212,6 +218,7 @@ void RequestSipEvent::linkTransactions(){
(ot=dynamic_pointer_cast<OutgoingTransaction>(mOutgoingAgent))!=NULL &&
(it=dynamic_pointer_cast<IncomingTransaction>(mIncomingAgent))!=NULL){
ot->mIncoming=it;
it->mOutgoing=ot;
}
}
......
......@@ -80,20 +80,30 @@ const url_t *OutgoingTransaction::getRequestUri()const{
}
void OutgoingTransaction::send(const shared_ptr<MsgSip> &ms, url_string_t const *u, tag_type_t tag, tag_value_t value, ...) {
msg_t* msg = msg_dup(ms->getMsg());
ta_list ta;
ta_start(ta, tag, value);
LOGD("Message is sent through an outgoing transaction.");
mOutgoing = nta_outgoing_mcreate(mAgent->mAgent, OutgoingTransaction::_callback, (nta_outgoing_magic_t*) this, u, msg, ta_tags(ta),TAG_END());
ta_end(ta);
if (mOutgoing == NULL) {
LOGE("Error during outgoing transaction creation");
msg_destroy(msg);
} else {
mSofiaRef = shared_from_this();
mAgent->sendTransactionEvent(TransactionEvent::makeCreate(shared_from_this()));
}
if (!mOutgoing){
msg_t* msg = msg_dup(ms->getMsg());
ta_start(ta, tag, value);
mOutgoing = nta_outgoing_mcreate(mAgent->mAgent, OutgoingTransaction::_callback, (nta_outgoing_magic_t*) this, u, msg, ta_tags(ta),TAG_END());
ta_end(ta);
if (mOutgoing == NULL) {
LOGE("Error during outgoing transaction creation");
msg_destroy(msg);
} else {
mSofiaRef = shared_from_this();
mAgent->sendTransactionEvent(TransactionEvent::makeCreate(shared_from_this()));
}
}else{
//sofia transaction already created, this happens when attempting to forward a cancel
if (ms->getSip()->sip_request->rq_method==sip_method_cancel){
cancel();
}else{
LOGE("Attempting to send request %s through an already created outgoing transaction.",ms->getSip()->sip_request->rq_method_name);
}
}
}
int OutgoingTransaction::_callback(nta_outgoing_magic_t *magic, nta_outgoing_t *irq, const sip_t *sip) {
......@@ -212,5 +222,6 @@ void IncomingTransaction::destroy() {
nta_incoming_bind(mIncoming, NULL, NULL); //avoid callbacks
nta_incoming_destroy(mIncoming);
looseProperties();
mOutgoing.reset();
}
}
......@@ -168,7 +168,8 @@ public:
inline virtual Agent *getAgent() {
return Transaction::getAgent();
}
///The outgoing transaction that was eventually created to forward the message through a RequestSipEvent.
std::shared_ptr<OutgoingTransaction> mOutgoing;
private:
friend class RequestSipEvent;
IncomingTransaction(Agent *agent);
......
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