mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Implement max # of forwards (bug #2942, different strategy)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4351 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -122,6 +122,7 @@ struct localuser {
|
|||||||
int allowdisconnect_in;
|
int allowdisconnect_in;
|
||||||
int allowdisconnect_out;
|
int allowdisconnect_out;
|
||||||
int forcecallerid;
|
int forcecallerid;
|
||||||
|
int forwards;
|
||||||
struct localuser *next;
|
struct localuser *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -141,6 +142,8 @@ static void hanguptree(struct localuser *outgoing, struct ast_channel *exception
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define AST_MAX_FORWARDS 8
|
||||||
|
|
||||||
#define AST_MAX_WATCHERS 256
|
#define AST_MAX_WATCHERS 256
|
||||||
|
|
||||||
#define HANDLE_CAUSE(blah, bleh) do { \
|
#define HANDLE_CAUSE(blah, bleh) do { \
|
||||||
@@ -255,12 +258,21 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
|
|||||||
tech = "Local";
|
tech = "Local";
|
||||||
}
|
}
|
||||||
/* Before processing channel, go ahead and check for forwarding */
|
/* Before processing channel, go ahead and check for forwarding */
|
||||||
if (option_verbose > 2)
|
o->forwards++;
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name);
|
if (o->forwards < AST_MAX_FORWARDS) {
|
||||||
/* Setup parameters */
|
if (option_verbose > 2)
|
||||||
o->chan = ast_request(tech, in->nativeformats, stuff, &cause);
|
ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name);
|
||||||
|
/* Setup parameters */
|
||||||
|
o->chan = ast_request(tech, in->nativeformats, stuff, &cause);
|
||||||
|
if (!o->chan)
|
||||||
|
ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
|
||||||
|
} else {
|
||||||
|
if (option_verbose > 2)
|
||||||
|
ast_verbose(VERBOSE_PREFIX_3 "Too many forwards from %s\n", o->chan->name);
|
||||||
|
cause = AST_CAUSE_CONGESTION;
|
||||||
|
o->chan = NULL;
|
||||||
|
}
|
||||||
if (!o->chan) {
|
if (!o->chan) {
|
||||||
ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
|
|
||||||
o->stillgoing = 0;
|
o->stillgoing = 0;
|
||||||
HANDLE_CAUSE(cause, in);
|
HANDLE_CAUSE(cause, in);
|
||||||
} else {
|
} else {
|
||||||
@@ -804,14 +816,23 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
|||||||
stuff = tmpchan;
|
stuff = tmpchan;
|
||||||
tech = "Local";
|
tech = "Local";
|
||||||
}
|
}
|
||||||
/* Before processing channel, go ahead and check for forwarding */
|
tmp->forwards++;
|
||||||
if (option_verbose > 2)
|
if (tmp->forwards < AST_MAX_FORWARDS) {
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Forwarding %s to '%s/%s' (thanks to %s)\n", chan->name, tech, stuff, tmp->chan->name);
|
if (option_verbose > 2)
|
||||||
/* Setup parameters */
|
ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", chan->name, tech, stuff, tmp->chan->name);
|
||||||
ast_hangup(tmp->chan);
|
ast_hangup(tmp->chan);
|
||||||
tmp->chan = ast_request(tech, chan->nativeformats, stuff, &cause);
|
/* Setup parameters */
|
||||||
|
tmp->chan = ast_request(tech, chan->nativeformats, stuff, &cause);
|
||||||
|
if (!tmp->chan)
|
||||||
|
ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
|
||||||
|
} else {
|
||||||
|
if (option_verbose > 2)
|
||||||
|
ast_verbose(VERBOSE_PREFIX_3 "Too many forwards from %s\n", tmp->chan->name);
|
||||||
|
ast_hangup(tmp->chan);
|
||||||
|
tmp->chan = NULL;
|
||||||
|
cause = AST_CAUSE_CONGESTION;
|
||||||
|
}
|
||||||
if (!tmp->chan) {
|
if (!tmp->chan) {
|
||||||
ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause %d)\n", tech, stuff, cause);
|
|
||||||
HANDLE_CAUSE(cause, chan);
|
HANDLE_CAUSE(cause, chan);
|
||||||
cur = rest;
|
cur = rest;
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user