When a calls B, if B has already connected the phone, but 200 OK has not returned to a, but a hangs up the phone
1. A sends Cancel to B.
2. A receives the 200 OK message from invite, replies to ACK, and sets the call to active.
3. B receives the cancel and replies to the 200 OK message, but does not send the 487
(Normal cancel process reference http://yeyingxian.blog.163.com/blog/static/344712420130238404943)
A opensips B
====> Invite
====> Invite
<=== 100 trying
<==== 200 OK (invite)
====> Cancel
====> Cancel
<==== 200 OK (invite)
====> ACK
<= 200 OK (cancel)
<= 200 OK (cancel)
====> ACK
Sequence Chart
The result is that a wants to stop the call, but the call is secretly connected.
Correction Method: When a is in the cancel process, if the 200 OK message is received, the bye message is sent to cancel the session.
Inv_set_state in sip_inv.c
If (pjmedia_sdp_neg_get_state (INV-> NEG )! = Pjmedia_sdp_neg_state_done &&
(Tsx_inv_data &&! Tsx_inv_data-> sdp_done ))
{
Pjsip_tx_data * Bye;
Pj_log (4, (INV-> obj_name, "SDP offer/Answer incomplete, ending"
"Session "));
Status = pjsip_inv_end_session (INV, pjsip_ SC _not_acceptable,
Null, & bye );
If (status = pj_success & bye)
Status = pjsip_inv_send_msg (INV, bye );
Return;
}
+ If (INV-> canceling)
+ {
+ Pjsip_tx_data * Bye;
+
+ Pj_log (4, (INV-> obj_name, "end session, because cancellation is in progress "));
+
+ Status = pjsip_inv_end_session (INV, pjsip_ SC _not_acceptable,
+ Null, & bye );
+ If (status = pj_success & bye)
+ Status = pjsip_inv_send_msg (INV, bye );
+
+ Return;
+}
}
/* Set state .*/
Inv-> state = State;