dect
/
asterisk
Archived
13
0
Fork 0

Don't segfault if chan_zap can't load

git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3281 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
markster 2004-06-23 01:27:44 +00:00
parent 28199081e9
commit 6f7decf268
1 changed files with 47 additions and 43 deletions

View File

@ -5768,47 +5768,6 @@ static struct zt_pvt *mkintf(int channel, int signalling, int radio, struct zt_p
for (x=0;x<3;x++)
tmp->subs[x].zfd = -1;
tmp->channel = channel;
/* nothing on the iflist */
if (!*wlist) {
*wlist = tmp;
tmp->prev = NULL;
tmp->next = NULL;
*wend = tmp;
} else {
/* at least one member on the iflist */
struct zt_pvt *working = *wlist;
/* check if we maybe have to put it on the begining */
if (working->channel > tmp->channel) {
tmp->next = *wlist;
tmp->prev = NULL;
*wlist = tmp;
} else {
/* go through all the members and put the member in the right place */
while (working) {
/* in the middle */
if (working->next) {
if (working->channel < tmp->channel && working->next->channel > tmp->channel) {
tmp->next = working->next;
tmp->prev = working;
working->next->prev = tmp;
working->next = tmp;
break;
}
} else {
/* the last */
if (working->channel < tmp->channel) {
working->next = tmp;
tmp->next = NULL;
tmp->prev = working;
*wend = tmp;
break;
}
}
working = working->next;
}
}
}
}
if (tmp) {
@ -6129,6 +6088,50 @@ static struct zt_pvt *mkintf(int channel, int signalling, int radio, struct zt_p
}
if (si.alarms) tmp->inalarm = 1;
}
}
if (tmp && !here) {
/* nothing on the iflist */
if (!*wlist) {
*wlist = tmp;
tmp->prev = NULL;
tmp->next = NULL;
*wend = tmp;
} else {
/* at least one member on the iflist */
struct zt_pvt *working = *wlist;
/* check if we maybe have to put it on the begining */
if (working->channel > tmp->channel) {
tmp->next = *wlist;
tmp->prev = NULL;
*wlist = tmp;
} else {
/* go through all the members and put the member in the right place */
while (working) {
/* in the middle */
if (working->next) {
if (working->channel < tmp->channel && working->next->channel > tmp->channel) {
tmp->next = working->next;
tmp->prev = working;
working->next->prev = tmp;
working->next = tmp;
break;
}
} else {
/* the last */
if (working->channel < tmp->channel) {
working->next = tmp;
tmp->next = NULL;
tmp->prev = working;
*wend = tmp;
break;
}
}
working = working->next;
}
}
}
}
return tmp;
}
@ -8262,7 +8265,7 @@ static int __unload_module(void)
return -1;
}
if (!ast_mutex_lock(&monlock)) {
if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) {
if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP) && (monitor_thread != AST_PTHREADT_NULL)) {
pthread_cancel(monitor_thread);
pthread_kill(monitor_thread, SIGURG);
pthread_join(monitor_thread, NULL);
@ -8301,7 +8304,8 @@ static int __unload_module(void)
}
#ifdef ZAPATA_PRI
for(i=0;i<NUM_SPANS;i++) {
pthread_join(pris[i].master, NULL);
if (pris[i].master && (pris[i].master != AST_PTHREADT_NULL))
pthread_join(pris[i].master, NULL);
zt_close(pris[i].fds[i]);
}
#endif