[asterisk-commits] kpfleming: branch 1.4 r147429 - /branches/1.4/channels/chan_dahdi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Oct 7 17:59:08 CDT 2008


Author: kpfleming
Date: Tue Oct  7 17:59:08 2008
New Revision: 147429

URL: http://svn.digium.com/view/asterisk?view=rev&rev=147429
Log:
don't start a PBX on incoming PRI call channels until after we're done setting channel variables and other things on the channel, otherwise the channel might go away (if the dialplan hangs up quickly) before we are done, which results in a spectacular crash


Modified:
    branches/1.4/channels/chan_dahdi.c

Modified: branches/1.4/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_dahdi.c?view=diff&rev=147429&r1=147428&r2=147429
==============================================================================
--- branches/1.4/channels/chan_dahdi.c (original)
+++ branches/1.4/channels/chan_dahdi.c Tue Oct  7 17:59:08 2008
@@ -9080,10 +9080,16 @@
 							}
 							pthread_attr_destroy(&attr);
 						} else  {
+							/* Release PRI lock while we create the channel */
 							ast_mutex_unlock(&pri->lock);
-							/* Release PRI lock while we create the channel */
-							c = dahdi_new(pri->pvts[chanpos], AST_STATE_RING, 1, SUB_REAL, law, e->ring.ctype);
-							if (c) {
+
+							if (!(c = dahdi_new(pri->pvts[chanpos], AST_STATE_RING, 0, SUB_REAL, law, e->ring.ctype))) {
+								ast_mutex_lock(&pri->lock);
+								ast_log(LOG_WARNING, "Unable to create channel for %d/%d, span %d\n", 
+									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
+								pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION);
+								pri->pvts[chanpos]->call = NULL;
+							} else {
 								char calledtonstr[10];
 
 								ast_mutex_unlock(&pri->pvts[chanpos]->lock);
@@ -9110,17 +9116,17 @@
 
 								if (option_verbose > 2)
 									ast_verbose(VERBOSE_PREFIX_3 "Accepting call from '%s' to '%s' on channel %d/%d, span %d\n",
-										plancallingnum, pri->pvts[chanpos]->exten, 
-											pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
-								dahdi_enable_ec(pri->pvts[chanpos]);
-							} else {
-
-								ast_mutex_lock(&pri->lock);
-
-								ast_log(LOG_WARNING, "Unable to start PBX on channel %d/%d, span %d\n", 
-									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
-								pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION);
-								pri->pvts[chanpos]->call = NULL;
+										    plancallingnum, pri->pvts[chanpos]->exten, 
+										    pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
+								if (ast_pbx_start(c)) {
+									ast_log(LOG_WARNING, "Unable to start PBX on %s\n", c->name);
+									ast_hangup(c);
+									pri->pvts[chanpos]->owner = NULL;
+									pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION);
+									pri->pvts[chanpos]->call = NULL;
+								} else {
+									dahdi_enable_ec(pri->pvts[chanpos]);
+								}
 							}
 						}
 					} else {




More information about the asterisk-commits mailing list