diff options
Diffstat (limited to 'res/res_pjsip_pubsub.c')
-rw-r--r-- | res/res_pjsip_pubsub.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c index 8b37dd07b..643ed850f 100644 --- a/res/res_pjsip_pubsub.c +++ b/res/res_pjsip_pubsub.c @@ -1559,6 +1559,28 @@ void *ast_sip_subscription_get_header(const struct ast_sip_subscription *sub, co return pjsip_msg_find_hdr_by_name(msg, &name, NULL); } +/*! + * \internal + * \brief Wrapper for pjsip_evsub_send_request + * + * 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_evsub_send_request(struct sip_subscription_tree *sub_tree, pjsip_tx_data *tdata) +{ + pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, }; + + ast_sip_set_tpselector_from_transport_name(sub_tree->endpoint->transport, &selector); + pjsip_dlg_set_transport(sub_tree->dlg, &selector); + + return pjsip_evsub_send_request(sub_tree->evsub, tdata); +} + /* XXX This function is not used. */ struct ast_sip_subscription *ast_sip_create_subscription(const struct ast_sip_subscription_handler *handler, struct ast_sip_endpoint *endpoint, const char *resource) @@ -1606,7 +1628,7 @@ struct ast_sip_subscription *ast_sip_create_subscription(const struct ast_sip_su evsub = sub_tree->evsub; if (pjsip_evsub_initiate(evsub, NULL, -1, &tdata) == PJ_SUCCESS) { - pjsip_evsub_send_request(evsub, tdata); + internal_pjsip_evsub_send_request(sub_tree, tdata); } else { /* pjsip_evsub_terminate will result in pubsub_on_evsub_state, * being called and terminating the subscription. Therefore, we don't @@ -1687,8 +1709,8 @@ static int sip_subscription_send_request(struct sip_subscription_tree *sub_tree, { #ifdef TEST_FRAMEWORK struct ast_sip_endpoint *endpoint = sub_tree->endpoint; -#endif pjsip_evsub *evsub = sub_tree->evsub; +#endif int res; if (allocate_tdata_buffer(tdata)) { @@ -1696,7 +1718,8 @@ static int sip_subscription_send_request(struct sip_subscription_tree *sub_tree, return -1; } - res = pjsip_evsub_send_request(evsub, tdata) == PJ_SUCCESS ? 0 : -1; + res = internal_pjsip_evsub_send_request(sub_tree, tdata); + subscription_persistence_update(sub_tree, NULL); ast_test_suite_event_notify("SUBSCRIPTION_STATE_SET", @@ -1705,7 +1728,7 @@ static int sip_subscription_send_request(struct sip_subscription_tree *sub_tree, pjsip_evsub_get_state_name(evsub), ast_sorcery_object_get_id(endpoint)); - return res; + return (res == PJ_SUCCESS ? 0 : -1); } /*! |