if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
+ tmp->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
ast_hangup(tmp);
tmp = NULL;
}
chan2m = ast_channel_alloc(0);
if ((!chan2m) || (!chan1m)) {
if (chan1m)
+ chan1m->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
ast_hangup(chan1m);
if (chan2m)
+ chan2m->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
ast_hangup(chan2m);
return -1;
}
if (ast_do_masquerade(chan2m)) {
ast_log(LOG_WARNING, "Masquerade failed :(\n");
ast_mutex_unlock(&chan2m->lock);
+ chan2m->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
ast_hangup(chan2m);
return -1;
}
}
if (res) {
- ast_log(LOG_WARNING, "Failed to start PBX :(\n");
/* Unlock locks so ast_hangup can do its magic */
ast_mutex_unlock(&c->lock);
ast_mutex_unlock(&p->lock);
ast_set_flag(p, SIP_ALREADYGONE);
/* Unlock locks so ast_hangup can do its magic */
ast_mutex_unlock(&p->lock);
+ c->hangupcause = AST_CAUSE_CALL_REJECTED;
ast_hangup(c);
ast_mutex_lock(&p->lock);
c = NULL;
} else {
ast_mutex_unlock(&p->lock);
ast_setstate(c, AST_STATE_DOWN);
+ c->hangupcause = AST_CAUSE_NORMAL_CLEARING;
ast_hangup(c);
ast_mutex_lock(&p->lock);
c = NULL;