summaryrefslogtreecommitdiff
path: root/channels/chan_zap.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2003-08-07 03:48:00 +0000
committerMark Spencer <markster@digium.com>2003-08-07 03:48:00 +0000
commit01fcb9779aa48bdf31c222dd58e1cbe5c6077dfd (patch)
treebf0bf6fdb84162c0fc1e4e237f57ece2dd11d309 /channels/chan_zap.c
parent58022ed110723fea923fa6836c75d149493c0071 (diff)
Allow groups to be checked in reverse order, make musiconhold die on restart
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1269 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_zap.c')
-rwxr-xr-xchannels/chan_zap.c41
1 files changed, 35 insertions, 6 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 915d5e912..37c999195 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -355,6 +355,7 @@ static struct zt_pvt {
float rxgain;
float txgain;
struct zt_pvt *next; /* Next channel in list */
+ struct zt_pvt *prev; /* Prev channel in list */
char context[AST_MAX_EXTENSION];
char exten[AST_MAX_EXTENSION];
char language[MAX_LANGUAGE];
@@ -448,7 +449,7 @@ static struct zt_pvt {
int r2blocked;
int sigchecked;
#endif
-} *iflist = NULL;
+} *iflist = NULL, *ifend = NULL;
#ifdef ZAPATA_PRI
static inline int pri_grab(struct zt_pvt *pvt, struct zt_pri *pri)
@@ -1433,8 +1434,16 @@ static int destroy_channel(struct zt_pvt *prev, struct zt_pvt *cur, int now)
if (!owned) {
if (prev) {
prev->next = cur->next;
+ if (prev->next)
+ prev->next->prev = prev;
+ else
+ ifend = prev;
} else {
iflist = cur->next;
+ if (iflist)
+ iflist->prev = NULL;
+ else
+ ifend = NULL;
}
if (cur->subs[SUB_REAL].zfd > -1) {
zt_close(cur->subs[SUB_REAL].zfd);
@@ -1444,8 +1453,16 @@ static int destroy_channel(struct zt_pvt *prev, struct zt_pvt *cur, int now)
} else {
if (prev) {
prev->next = cur->next;
+ if (prev->next)
+ prev->next->prev = prev;
+ else
+ ifend = prev;
} else {
iflist = cur->next;
+ if (iflist)
+ iflist->prev = NULL;
+ else
+ ifend = NULL;
}
if (cur->subs[SUB_REAL].zfd > -1) {
zt_close(cur->subs[SUB_REAL].zfd);
@@ -4743,11 +4760,14 @@ static struct zt_pvt *mkintf(int channel, int signalling, int radio)
for (x=0;x<3;x++)
tmp->subs[x].zfd = -1;
tmp->next = tmp2;
- if (!prev) {
+ if (!ifend) {
iflist = tmp;
+ tmp->prev = NULL;
} else {
- prev->next = tmp;
+ ifend->next = tmp;
+ tmp->prev = ifend;
}
+ ifend = tmp;
}
if (tmp) {
@@ -5141,6 +5161,7 @@ static struct ast_channel *zt_request(char *type, int format, void *data)
char *s;
char opt=0;
int res=0, y=0;
+ int backwards = 0;
/* We do signed linear */
oldformat = format;
@@ -5155,7 +5176,7 @@ static struct ast_channel *zt_request(char *type, int format, void *data)
ast_log(LOG_WARNING, "Channel requested with no data\n");
return NULL;
}
- if (dest[0] == 'g') {
+ if (toupper(dest[0]) == 'G') {
/* Retrieve the group number */
char *stringp=NULL;
stringp=dest + 1;
@@ -5166,6 +5187,8 @@ static struct ast_channel *zt_request(char *type, int format, void *data)
return NULL;
}
groupmatch = 1 << x;
+ if (dest[0] == 'G')
+ backwards = 1;
} else {
char *stringp=NULL;
stringp=dest;
@@ -5185,7 +5208,10 @@ static struct ast_channel *zt_request(char *type, int format, void *data)
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
return NULL;
}
- p = iflist;
+ if (backwards)
+ p = ifend;
+ else
+ p = iflist;
while(p && !tmp) {
if (available(p, channelmatch, groupmatch)) {
if (option_debug)
@@ -5232,7 +5258,10 @@ static struct ast_channel *zt_request(char *type, int format, void *data)
tmp->cdrflags |= AST_CDR_CALLWAIT;
break;
}
- p = p->next;
+ if (backwards)
+ p = p->prev;
+ else
+ p = p->next;
}
ast_pthread_mutex_unlock(&iflock);
restart_monitor();