summaryrefslogtreecommitdiff
path: root/res/res_pjsip_session.c
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2016-02-11 10:01:05 -0700
committerGeorge Joseph <george.joseph@fairview5.com>2016-02-19 18:57:55 -0600
commitba8adb4ce3ac15198b0dfe38df890d4283ad9bc8 (patch)
treeb739fd5001c12ae8d33c72a20203d65857676c9f /res/res_pjsip_session.c
parent6fc57b3e1f401fd18e3e4d4462f973094dd0908c (diff)
res_pjsip/config_transport: Allow reloading transports.
The 'reload' mechanism actually involves closing the underlying socket and calling the appropriate udp, tcp or tls start functions again. Only outbound_registration, pubsub and session needed work to reset the transport before sending requests to insure that the pjsip transport didn't get pulled out from under them. In my testing, no calls were dropped when a transport was changed for any of the 3 transport types even if ip addresses or ports were changed. To be on the safe side however, a new transport option was added (allow_reload) which defaults to 'no'. Unless it's explicitly set to 'yes' for a transport, changes to that transport will be ignored on a reload of res_pjsip. This should preserve the current behavior. Change-Id: I5e759850e25958117d4c02f62ceb7244d7ec9edf
Diffstat (limited to 'res/res_pjsip_session.c')
-rw-r--r--res/res_pjsip_session.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index e7dd5b91d..983687174 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -888,10 +888,32 @@ int ast_sip_session_refresh(struct ast_sip_session *session,
return 0;
}
+/*!
+ * \internal
+ * \brief Wrapper for pjsip_inv_send_msg
+ *
+ * This function (re)sets the transport before sending to catch cases
+ * where the transport might have changed.
+ *
+ * If pjproject gives us the ability to resend, we'll only reset the transport
+ * if PJSIP_ETPNOTAVAIL is returned from send.
+ *
+ * \returns pj_status_t
+ */
+static pj_status_t internal_pjsip_inv_send_msg(pjsip_inv_session *inv, const char *transport_name, pjsip_tx_data *tdata)
+{
+ pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
+
+ ast_sip_set_tpselector_from_transport_name(transport_name, &selector);
+ pjsip_dlg_set_transport(inv->dlg, &selector);
+
+ return pjsip_inv_send_msg(inv, tdata);
+}
+
void ast_sip_session_send_response(struct ast_sip_session *session, pjsip_tx_data *tdata)
{
handle_outgoing_response(session, tdata);
- pjsip_inv_send_msg(session->inv_session, tdata);
+ internal_pjsip_inv_send_msg(session->inv_session, session->endpoint->transport, tdata);
return;
}
@@ -1087,7 +1109,8 @@ void ast_sip_session_send_request_with_cb(struct ast_sip_session *session, pjsip
}
handle_outgoing_request(session, tdata);
- pjsip_inv_send_msg(session->inv_session, tdata);
+ internal_pjsip_inv_send_msg(session->inv_session, session->endpoint->transport, tdata);
+
return;
}
@@ -1852,7 +1875,7 @@ static pjsip_inv_session *pre_session_setup(pjsip_rx_data *rdata, const struct a
if (pjsip_inv_initial_answer(inv_session, rdata, 500, NULL, NULL, &tdata) != PJ_SUCCESS) {
pjsip_inv_terminate(inv_session, 500, PJ_FALSE);
}
- pjsip_inv_send_msg(inv_session, tdata);
+ internal_pjsip_inv_send_msg(inv_session, endpoint->transport, tdata);
return NULL;
}
return inv_session;
@@ -2005,7 +2028,7 @@ static void handle_new_invite_request(pjsip_rx_data *rdata)
if (pjsip_inv_initial_answer(inv_session, rdata, 500, NULL, NULL, &tdata) == PJ_SUCCESS) {
pjsip_inv_terminate(inv_session, 500, PJ_FALSE);
} else {
- pjsip_inv_send_msg(inv_session, tdata);
+ internal_pjsip_inv_send_msg(inv_session, endpoint->transport, tdata);
}
return;
}
@@ -2015,7 +2038,7 @@ static void handle_new_invite_request(pjsip_rx_data *rdata)
if (pjsip_inv_initial_answer(inv_session, rdata, 500, NULL, NULL, &tdata) == PJ_SUCCESS) {
pjsip_inv_terminate(inv_session, 500, PJ_FALSE);
} else {
- pjsip_inv_send_msg(inv_session, tdata);
+ internal_pjsip_inv_send_msg(inv_session, endpoint->transport, tdata);
}
ao2_cleanup(invite);
}