Author: jrose Date: Wed Apr 8 13:32:31 2015 New Revision: 434431 URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=434431 Log: res_pjsip_t38: Fix FAX failures when using PJSIP with authentication
Without this patch, if a PJSIP endpoint with udptl enabled and authentication set attempted to use sendFax, the FAX session would fail during setup. This was because the invite issued in response to being auth challenged would cause the PJSIP channel performing the FAX to receive a second T38 framehook and this would cause frames to be consumed in an inappropriate manner. ASTERISK-24933 #close Reported by: Jonathan Rose Review: https://reviewboard.asterisk.org/r/4577/ ........ Merged revisions 434425 from http://svn.asterisk.org/svn/asterisk/branches/13 Modified: trunk/ (props changed) trunk/res/res_pjsip_t38.c Propchange: trunk/ ------------------------------------------------------------------------------ Binary property 'branch-13-merged' - no diff available. Modified: trunk/res/res_pjsip_t38.c URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_t38.c?view=diff&rev=434431&r1=434430&r2=434431 ============================================================================== --- trunk/res/res_pjsip_t38.c (original) +++ trunk/res/res_pjsip_t38.c Wed Apr 8 13:32:31 2015 @@ -453,9 +453,15 @@ ast_framehook_detach(new_chan, framehook_id); } +static const struct ast_datastore_info t38_framehook_datastore = { + .type = "T38 framehook", +}; + /*! \brief Function called to attach T.38 framehook to channel when appropriate */ static void t38_attach_framehook(struct ast_sip_session *session) { + int framehook_id; + struct ast_datastore *datastore = NULL; static struct ast_framehook_interface hook = { .version = AST_FRAMEHOOK_INTERFACE_VERSION, .event_cb = t38_framehook, @@ -463,17 +469,38 @@ .chan_breakdown_cb = t38_masq, }; - /* Only attach the framehook on the first outgoing INVITE or the first incoming INVITE */ - if ((session->inv_session->state != PJSIP_INV_STATE_NULL && - session->inv_session->state != PJSIP_INV_STATE_INCOMING) || - !session->endpoint->media.t38.enabled) { + /* Only attach the framehook if t38 is enabled for the endpoint */ + if (!session->endpoint->media.t38.enabled) { return; } - if (ast_framehook_attach(session->channel, &hook) < 0) { + /* Skip attaching the framehook if the T.38 datastore already exists for the channel */ + ast_channel_lock(session->channel); + if ((datastore = ast_channel_datastore_find(session->channel, &t38_framehook_datastore, NULL))) { + ast_channel_unlock(session->channel); + return; + } + ast_channel_unlock(session->channel); + + framehook_id = ast_framehook_attach(session->channel, &hook); + if (framehook_id < 0) { ast_log(LOG_WARNING, "Could not attach T.38 Frame hook to channel, T.38 will be unavailable on '%s'\n", ast_channel_name(session->channel)); - } + return; + } + + ast_channel_lock(session->channel); + datastore = ast_datastore_alloc(&t38_framehook_datastore, NULL); + if (!datastore) { + ast_log(LOG_ERROR, "Could not attach T.38 Frame hook to channel, T.38 will be unavailable on '%s'\n", + ast_channel_name(session->channel)); + ast_framehook_detach(session->channel, framehook_id); + ast_channel_unlock(session->channel); + return; + } + + ast_channel_datastore_add(session->channel, datastore); + ast_channel_unlock(session->channel); } /*! \brief Function called when an INVITE goes out */ -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- svn-commits mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/svn-commits