[asterisk-commits] mnicholson: branch irroot/t38gateway-trunk r324616 - /team/irroot/t38gateway-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 23 09:15:35 CDT 2011


Author: mnicholson
Date: Thu Jun 23 09:15:31 2011
New Revision: 324616

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=324616
Log:
make the gateway timeout after 10 seconds if there has been no fax activity

Modified:
    team/irroot/t38gateway-trunk/res/res_fax.c

Modified: team/irroot/t38gateway-trunk/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/t38gateway-trunk/res/res_fax.c?view=diff&rev=324616&r1=324615&r2=324616
==============================================================================
--- team/irroot/t38gateway-trunk/res/res_fax.c (original)
+++ team/irroot/t38gateway-trunk/res/res_fax.c Thu Jun 23 09:15:31 2011
@@ -256,6 +256,8 @@
 	struct ast_fax_session *s;
 	/*! reserved fax session token */
 	struct ast_fax_tech_token *token;
+	/*! the start of the bridge */
+	struct timeval bridge_start;
 	/*! DSP Processor*/
 	struct ast_dsp *chan_dsp;
 	struct ast_dsp *peer_dsp;
@@ -278,6 +280,7 @@
 #define FAX_MAXBUCKETS 10
 
 #define RES_FAX_TIMEOUT 10000
+#define FAX_GATEWAY_TIMEOUT RES_FAX_TIMEOUT
 
 /*! \brief The faxregistry is used to manage information and statistics for all FAX sessions. */
 static struct {
@@ -2407,6 +2410,9 @@
 		return -1;
 	}
 
+	gateway->bridge_start.tv_sec = 0;
+	gateway->bridge_start.tv_usec = 0;
+
 	report_fax_status(chan, details, "FAX Transmission In Progress");
 
 	return 0;
@@ -2458,6 +2464,7 @@
 			}
 
 			gateway->t38_state = T38_STATE_NEGOTIATING;
+			gateway->bridge_start = ast_tvnow();
 
 			ast_debug(1, "detected CED tone on %s, requesting T.38 on %s for T.38 gateway session\n", active->name, other->name);
 			return f;
@@ -2523,6 +2530,7 @@
 			 * channel rejects the request */
 			ast_debug(1, "%s is attempting to negotiate T.38 with %s, we'll see what happens\n", active->name, other->name);
 			gateway->t38_state = T38_STATE_UNKNOWN;
+			gateway->bridge_start = ast_tvnow();
 			ao2_ref(details, -1);
 			return f;
 		} else if (state == T38_STATE_UNAVAILABLE || state == T38_STATE_REJECTED) {
@@ -2717,6 +2725,8 @@
 			return f;
 		}
 
+		gateway->bridge_start = ast_tvnow();
+
 		/* we are bridged, change r/w formats to SLIN for CED detection and T.30 */
 		ast_format_copy(&gateway->chan_read_format, &chan->readformat);
 		ast_format_copy(&gateway->chan_write_format, &chan->readformat);
@@ -2732,6 +2742,15 @@
 
 		ast_channel_make_compatible(chan, peer);
 		gateway->bridged = 1;
+	}
+
+	if (gateway->bridged && !ast_tvzero(gateway->bridge_start)) {
+		if (ast_tvdiff_ms(ast_tvnow(), gateway->bridge_start) >= FAX_GATEWAY_TIMEOUT) {
+			ast_debug(1, "no fax activity between %s and %s after %d ms, disabling gateway\n", chan->name, peer->name, FAX_GATEWAY_TIMEOUT);
+			ast_framehook_detach(chan, gateway->s->details->gateway_id);
+			gateway->s->details->gateway_id = -1;
+			return f;
+		}
 	}
 
 	/* only handle VOICE, MODEM, and CONTROL frames*/




More information about the asterisk-commits mailing list