[asterisk-commits] jrose: branch certified-13.1 r434428 - in /certified/branches/13.1: ./ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 8 13:19:29 CDT 2015


Author: jrose
Date: Wed Apr  8 13:19:26 2015
New Revision: 434428

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=434428
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:
    certified/branches/13.1/   (props changed)
    certified/branches/13.1/res/res_pjsip_t38.c

Propchange: certified/branches/13.1/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: certified/branches/13.1/res/res_pjsip_t38.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_pjsip_t38.c?view=diff&rev=434428&r1=434427&r2=434428
==============================================================================
--- certified/branches/13.1/res/res_pjsip_t38.c (original)
+++ certified/branches/13.1/res/res_pjsip_t38.c Wed Apr  8 13:19:26 2015
@@ -451,9 +451,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,
@@ -461,17 +467,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 */




More information about the asterisk-commits mailing list