aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-23 01:27:44 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-23 01:27:44 +0000
commit6f7decf268c345c21f2b4d2aea852cdb7a6ecfa0 (patch)
treeafe839f34daaa944d31dbcc0a510f8cce75df7fd /channels
parent28199081e9b0aec5a884e3232f270a3a48301ce4 (diff)
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
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_zap.c90
1 files changed, 47 insertions, 43 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 77547cda1..4682617ea 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -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