[Asterisk-cvs] asterisk/channels chan_zap.c,1.279,1.280

markster at lists.digium.com markster at lists.digium.com
Tue Jun 22 21:41:49 CDT 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv25308/channels

Modified Files:
	chan_zap.c 
Log Message:
Don't segfault if chan_zap can't load


Index: chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.279
retrieving revision 1.280
diff -u -d -r1.279 -r1.280
--- chan_zap.c	22 Jun 2004 17:42:13 -0000	1.279
+++ chan_zap.c	23 Jun 2004 01:27:44 -0000	1.280
@@ -5768,47 +5768,6 @@
 		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 @@
 			}
 			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 @@
 		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 @@
 	}
 #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




More information about the svn-commits mailing list