[asterisk-commits] rmudgett: branch rmudgett/sig_ss7 r261820 - /team/rmudgett/sig_ss7/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu May 6 15:51:27 CDT 2010
Author: rmudgett
Date: Thu May 6 15:51:24 2010
New Revision: 261820
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=261820
Log:
Convert ss7_start_call() to sig_ss7 environment.
* Fixed dahdi_new() module reference problem if the PBX failed to get
started. ast_hangup() would unreference the module when it had not been
referenced yet.
* Don't clear the owner pointer if the PBX fails to start in dahdi_new().
ast_hangup() will do it when the technology hangup callback is called.
Modified:
team/rmudgett/sig_ss7/channels/chan_dahdi.c
Modified: team/rmudgett/sig_ss7/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/sig_ss7/channels/chan_dahdi.c?view=diff&rev=261820&r1=261819&r2=261820
==============================================================================
--- team/rmudgett/sig_ss7/channels/chan_dahdi.c (original)
+++ team/rmudgett/sig_ss7/channels/chan_dahdi.c Thu May 6 15:51:24 2010
@@ -3211,7 +3211,7 @@
{
struct dahdi_pvt *p = pvt;
int audio;
- int newlaw = -1;
+ int newlaw;
/* Set to audio mode at this point */
audio = 1;
@@ -3226,6 +3226,7 @@
ast_copy_string(p->exten, exten, sizeof(p->exten));
+ newlaw = -1;
switch (law) {
case SIG_SS7_DEFLAW:
newlaw = 0;
@@ -3238,8 +3239,6 @@
break;
}
return dahdi_new(p, state, 0, SUB_REAL, newlaw, requestor ? requestor->linkedid : "");
-
- /*! \todo BUGBUG my_new_ss7_ast_channel() not written */
}
#endif /* defined(HAVE_SS7) */
@@ -9205,6 +9204,8 @@
for (v = i->vars ; v ; v = v->next)
pbx_builtin_setvar_helper(tmp, v->name, v->value);
+ ast_module_ref(ast_module_info->self);
+
if (startpbx) {
#ifdef HAVE_OPENR2
if (i->mfcr2call) {
@@ -9214,12 +9215,9 @@
if (ast_pbx_start(tmp)) {
ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
ast_hangup(tmp);
- i->owner = NULL;
return NULL;
}
}
-
- ast_module_ref(ast_module_info->self);
return tmp;
}
@@ -13227,49 +13225,49 @@
static void ss7_start_call(struct sig_ss7_chan *p, struct sig_ss7_linkset *linkset)
{
struct ss7 *ss7 = linkset->ss7;
- int res;
- int law = 1;
+ int law;
struct ast_channel *c;
char tmp[256];
-
- if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_AUDIOMODE, &law) == -1)
- ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d: %s\n", p->channel, law, strerror(errno));
-
- if (linkset->type == SS7_ITU)
- law = DAHDI_LAW_ALAW;
- else
- law = DAHDI_LAW_MULAW;
-
- res = dahdi_setlaw(p->subs[SUB_REAL].dfd, law);
- if (res < 0)
- ast_log(LOG_WARNING, "Unable to set law on channel %d\n", p->channel);
if (!(linkset->flags & LINKSET_FLAG_EXPLICITACM)) {
p->proceeding = 1;
isup_acm(ss7, p->ss7call);
}
+ if (linkset->type == SS7_ITU) {
+ law = SIG_SS7_ALAW;
+ } else {
+ law = SIG_SS7_ULAW;
+ }
+
+ /*
+ * Release the SS7 lock while we create the channel
+ * so other threads can send messages.
+ */
ast_mutex_unlock(&linkset->lock);
- /* BUGBUG do not call dahdi_new() with the startpbx flag set here! MUST FIX */
- /* BUGBUG convert code here to use sig_ss7_new_ast_channel() */
- c = dahdi_new(p, AST_STATE_RING, 1, SUB_REAL, law, NULL);
+ c = sig_ss7_new_ast_channel(p, AST_STATE_RING, law, 0, p->exten, NULL);
if (!c) {
ast_log(LOG_WARNING, "Unable to start PBX on CIC %d\n", p->cic);
- /* Holding this lock is assumed entering the function */
ast_mutex_lock(&linkset->lock);
+ isup_rel(linkset->ss7, p->ss7call, -1);
+ p->proceeding = 0;
+ p->alreadyhungup = 1;
return;
- } else
- ast_verb(3, "Accepting call to '%s' on CIC %d\n", p->exten, p->cic);
+ }
sig_ss7_set_echocanceller(p, 1);
- /* We only reference these variables in the context of the ss7_linkset function
- * when receiving either and IAM or a COT message. Since they are only accessed
- * from this context, we should be safe to unlock around them */
-
- sig_ss7_unlock_private(p);
-
- /*! \todo XXX SS7 Crash possible because we are setting channel variables after starting the PBX! */
+ /*
+ * It is reasonably safe to set the following
+ * channel variables while the channel private
+ * structure is locked. The PBX has not been
+ * started yet and it is unlikely that any other task
+ * will do anything with the channel we have just
+ * created.
+ *
+ * We only reference these variables in the context of the ss7_linkset function
+ * when receiving either and IAM or a COT message.
+ */
if (!ast_strlen_zero(p->charge_number)) {
pbx_builtin_setvar_helper(c, "SS7_CHARGE_NUMBER", p->charge_number);
/* Clear this after we set it */
@@ -13338,7 +13336,12 @@
p->generic_name[0] = 0;
}
- sig_ss7_lock_private(p);
+ if (ast_pbx_start(c)) {
+ ast_log(LOG_WARNING, "Unable to start PBX on %s (CIC %d)\n", c->name, p->cic);
+ ast_hangup(c);
+ } else {
+ ast_verb(3, "Accepting call to '%s' on CIC %d\n", p->exten, p->cic);
+ }
ast_mutex_lock(&linkset->lock);
}
#endif /* defined(HAVE_SS7) */
More information about the asterisk-commits
mailing list