[Asterisk-code-review] res pjsip session.c: Send 100 Trying out earlier to prevent ... (asterisk[13])
Richard Mudgett
asteriskteam at digium.com
Fri Apr 21 14:45:23 CDT 2017
Richard Mudgett has uploaded a new change for review. ( https://gerrit.asterisk.org/5514 )
Change subject: res_pjsip_session.c: Send 100 Trying out earlier to prevent retransmissions.
......................................................................
res_pjsip_session.c: Send 100 Trying out earlier to prevent retransmissions.
If ICE is enabled and a STUN server does not respond then we will block
until we give up on the STUN response. This will take nine seconds. In
the mean time the peer that sent the INVITE will send retransmissions.
* Restructure res_pjsip_session.c:new_invite() to send a 100 Trying out
earlier to prevent these retransmissions.
ASTERISK-26890
Change-Id: Ie3fc611e53a0eff6586ad55e4aacad81cf6319a8
---
M res/res_pjsip_session.c
1 file changed, 29 insertions(+), 24 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/14/5514/1
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index a3110f5..7bd0063 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -2148,12 +2148,29 @@
goto end;
};
- if ((sdp_info = pjsip_rdata_get_sdp_info(invite->rdata)) && (sdp_info->sdp_err == PJ_SUCCESS) && sdp_info->sdp) {
+ pjsip_timer_setting_default(&timer);
+ timer.min_se = invite->session->endpoint->extensions.timer.min_se;
+ timer.sess_expires = invite->session->endpoint->extensions.timer.sess_expires;
+ pjsip_timer_init_session(invite->session->inv_session, &timer);
+
+ /*
+ * At this point, we've verified what we can that won't take awhile,
+ * so let's go ahead and send a 100 Trying out to stop any
+ * retransmissions.
+ */
+ if (pjsip_inv_initial_answer(invite->session->inv_session, invite->rdata, 100, NULL, NULL, &tdata) != PJ_SUCCESS) {
+ pjsip_inv_terminate(invite->session->inv_session, 500, PJ_TRUE);
+ goto end;
+ }
+ ast_sip_session_send_response(invite->session, tdata);
+
+ sdp_info = pjsip_rdata_get_sdp_info(invite->rdata);
+ if (sdp_info && (sdp_info->sdp_err == PJ_SUCCESS) && sdp_info->sdp) {
if (handle_incoming_sdp(invite->session, sdp_info->sdp)) {
- if (pjsip_inv_initial_answer(invite->session->inv_session, invite->rdata, 488, NULL, NULL, &tdata) == PJ_SUCCESS) {
+ tdata = NULL;
+ if (pjsip_inv_end_session(invite->session->inv_session, 488, NULL, &tdata) == PJ_SUCCESS
+ && tdata) {
ast_sip_session_send_response(invite->session, tdata);
- } else {
- pjsip_inv_terminate(invite->session->inv_session, 488, PJ_TRUE);
}
goto end;
}
@@ -2166,31 +2183,19 @@
/* If we were unable to create a local SDP terminate the session early, it won't go anywhere */
if (!local) {
- if (pjsip_inv_initial_answer(invite->session->inv_session, invite->rdata, 500, NULL, NULL, &tdata) == PJ_SUCCESS) {
+ tdata = NULL;
+ if (pjsip_inv_end_session(invite->session->inv_session, 500, NULL, &tdata) == PJ_SUCCESS
+ && tdata) {
ast_sip_session_send_response(invite->session, tdata);
- } else {
- pjsip_inv_terminate(invite->session->inv_session, 500, PJ_TRUE);
}
goto end;
- } else {
- pjsip_inv_set_local_sdp(invite->session->inv_session, local);
- pjmedia_sdp_neg_set_prefer_remote_codec_order(invite->session->inv_session->neg, PJ_FALSE);
+ }
+
+ pjsip_inv_set_local_sdp(invite->session->inv_session, local);
+ pjmedia_sdp_neg_set_prefer_remote_codec_order(invite->session->inv_session->neg, PJ_FALSE);
#ifdef PJMEDIA_SDP_NEG_ANSWER_MULTIPLE_CODECS
- pjmedia_sdp_neg_set_answer_multiple_codecs(invite->session->inv_session->neg, PJ_TRUE);
+ pjmedia_sdp_neg_set_answer_multiple_codecs(invite->session->inv_session->neg, PJ_TRUE);
#endif
- }
-
- pjsip_timer_setting_default(&timer);
- timer.min_se = invite->session->endpoint->extensions.timer.min_se;
- timer.sess_expires = invite->session->endpoint->extensions.timer.sess_expires;
- pjsip_timer_init_session(invite->session->inv_session, &timer);
-
- /* At this point, we've verified what we can, so let's go ahead and send a 100 Trying out */
- if (pjsip_inv_initial_answer(invite->session->inv_session, invite->rdata, 100, NULL, NULL, &tdata) != PJ_SUCCESS) {
- pjsip_inv_terminate(invite->session->inv_session, 500, PJ_TRUE);
- goto end;
- }
- ast_sip_session_send_response(invite->session, tdata);
handle_incoming_request(invite->session, invite->rdata);
--
To view, visit https://gerrit.asterisk.org/5514
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie3fc611e53a0eff6586ad55e4aacad81cf6319a8
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
More information about the asterisk-code-review
mailing list