diff options
author | rmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-03-10 16:55:34 +0000 |
---|---|---|
committer | rmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-03-10 16:55:34 +0000 |
commit | 090c22992b8ebd9b0de86374da8347130afc70b6 (patch) | |
tree | c08b4dad147a4d30292029f7ab4513b6f0c3f5ab /channels | |
parent | 8bb352d623b242752a3e876d37961e2663f77def (diff) |
Simplified dahdi_request() channel selection failed reason/cause code.
Also avoid potential crash because cause could be NULL.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@251585 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_dahdi.c | 25 | ||||
-rw-r--r-- | channels/sig_analog.c | 8 | ||||
-rw-r--r-- | channels/sig_analog.h | 2 | ||||
-rw-r--r-- | channels/sig_pri.c | 15 | ||||
-rw-r--r-- | channels/sig_pri.h | 2 |
5 files changed, 21 insertions, 31 deletions
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 5f1377ef8..18942a44e 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -11880,7 +11880,7 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf, return tmp; } -static inline int available(struct dahdi_pvt *p, int channelmatch, ast_group_t groupmatch, int *reason, int *channelmatched, int *groupmatched) +static inline int available(struct dahdi_pvt *p, int channelmatch, ast_group_t groupmatch, int *channelmatched, int *groupmatched) { /* First, check group matching */ if (groupmatch) { @@ -11899,12 +11899,12 @@ static inline int available(struct dahdi_pvt *p, int channelmatch, ast_group_t g return 0; if (analog_lib_handles(p->sig, p->radio, p->oprmode)) - return analog_available(p->sig_pvt, reason); + return analog_available(p->sig_pvt); #ifdef HAVE_PRI switch (p->sig) { case SIG_PRI_LIB_HANDLE_CASES: - return sig_pri_available(p->sig_pvt, reason); + return sig_pri_available(p->sig_pvt); default: break; } @@ -12094,7 +12094,6 @@ static struct ast_channel *dahdi_request(const char *type, format_t format, cons int channelmatch = -1; int roundrobin = 0; int callwait = 0; - int unavailreason = 0; struct dahdi_pvt *p; struct ast_channel *tmp = NULL; char *dest; @@ -12200,7 +12199,7 @@ static struct ast_channel *dahdi_request(const char *type, format_t format, cons ast_verbose("name = %s, %d, %d, %llu\n",p->owner ? p->owner->name : "<none>", p->channel, channelmatch, groupmatch); #endif - if (p && available(p, channelmatch, groupmatch, &unavailreason, &channelmatched, &groupmatched)) { + if (p && available(p, channelmatch, groupmatch, &channelmatched, &groupmatched)) { ast_debug(1, "Using channel %d\n", p->channel); callwait = (p->owner != NULL); @@ -12277,14 +12276,16 @@ next: } ast_mutex_unlock(&iflock); restart_monitor(); - if (callwait) - *cause = AST_CAUSE_BUSY; - else if (!tmp) { - if (channelmatched) { - if (unavailreason) - *cause = AST_CAUSE_BUSY; + if (cause && !tmp) { + if (callwait || channelmatched) { + *cause = AST_CAUSE_BUSY; } else if (groupmatched) { - *cause = (unavailreason) ? unavailreason : AST_CAUSE_CONGESTION; + *cause = AST_CAUSE_CONGESTION; + } else { + /* + * We did not match any channel requested. + * Dialplan error requesting non-existant channel? + */ } } diff --git a/channels/sig_analog.c b/channels/sig_analog.c index 3e8e9f317..8e4aa3391 100644 --- a/channels/sig_analog.c +++ b/channels/sig_analog.c @@ -649,17 +649,11 @@ struct ast_channel * analog_request(struct analog_pvt *p, int *callwait, const s return analog_new_ast_channel(p, AST_STATE_RESERVED, 0, p->owner ? ANALOG_SUB_CALLWAIT : ANALOG_SUB_REAL, requestor); } -int analog_available(struct analog_pvt *p, int *busy) +int analog_available(struct analog_pvt *p) { int offhook; ast_log(LOG_DEBUG, "%s %d\n", __FUNCTION__, p->channel); - /* We're at least busy at this point */ - if (busy) { - if ((p->sig == ANALOG_SIG_FXOKS) || (p->sig == ANALOG_SIG_FXOLS) || (p->sig == ANALOG_SIG_FXOGS)) { - *busy = 1; - } - } /* If do not disturb, definitely not */ if (p->dnd) { return 0; diff --git a/channels/sig_analog.h b/channels/sig_analog.h index 76972fe94..33b642289 100644 --- a/channels/sig_analog.h +++ b/channels/sig_analog.h @@ -336,7 +336,7 @@ struct ast_frame *analog_exception(struct analog_pvt *p, struct ast_channel *ast struct ast_channel * analog_request(struct analog_pvt *p, int *callwait, const struct ast_channel *requestor); -int analog_available(struct analog_pvt *p, int *busy); +int analog_available(struct analog_pvt *p); void *analog_handle_init_event(struct analog_pvt *i, int event); diff --git a/channels/sig_pri.c b/channels/sig_pri.c index c655e6deb..c1dff5f5e 100644 --- a/channels/sig_pri.c +++ b/channels/sig_pri.c @@ -3863,22 +3863,17 @@ int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast) return res; } -int sig_pri_available(struct sig_pri_chan *p, int *reason) +int sig_pri_available(struct sig_pri_chan *p) { /* If no owner and interface has a B channel then likely available */ if (!p->owner && !p->no_b_channel && p->pri) { + if (p->resetting || p->call #if defined(HAVE_PRI_SERVICE_MESSAGES) - if (p->resetting || p->call || p->service_status) { - if (p->service_status) { - *reason = AST_CAUSE_REQUESTED_CHAN_UNAVAIL; - } - return 0; - } -#else - if (p->resetting || p->call) { + || p->service_status +#endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */ + ) { return 0; } -#endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */ return 1; } diff --git a/channels/sig_pri.h b/channels/sig_pri.h index ed42ffd8f..2bb7ffc89 100644 --- a/channels/sig_pri.h +++ b/channels/sig_pri.h @@ -261,7 +261,7 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast); -int sig_pri_available(struct sig_pri_chan *p, int *reason); +int sig_pri_available(struct sig_pri_chan *p); void sig_pri_init_pri(struct sig_pri_pri *pri); |