[Asterisk-cvs] zaptel zaptel.c,1.54,1.55 zaptel.h,1.25,1.26

markster at lists.digium.com markster at lists.digium.com
Fri Feb 6 15:04:30 CST 2004


Update of /usr/cvsroot/zaptel
In directory mongoose.digium.com:/tmp/cvs-serv13485

Modified Files:
	zaptel.c zaptel.h 
Log Message:
Clear pseudos at end of interrupt handler ONLY


Index: zaptel.c
===================================================================
RCS file: /usr/cvsroot/zaptel/zaptel.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- zaptel.c	6 Jan 2004 13:26:44 -0000	1.54
+++ zaptel.c	6 Feb 2004 21:13:14 -0000	1.55
@@ -296,6 +296,10 @@
 
 static spinlock_t zaptimerlock = SPIN_LOCK_UNLOCKED;
 
+static spinlock_t zapfreelock = SPIN_LOCK_UNLOCKED;
+
+static int zapneedfree = 0;
+
 struct zt_zone {
 	char name[40];	/* Informational, only */
 	int ringcadence[ZT_MAX_CADENCE];
@@ -1458,6 +1462,17 @@
 };
 
 #endif
+
+static void __zt_recalc_maxchans(void)
+{
+	int x;
+	maxchans = 0;
+	for (x=1;x<ZT_MAX_CHANNELS;x++) 
+		if (chans[x]) {
+			maxchans = x + 1;
+		}
+}
+
 static void zt_chan_unreg(struct zt_chan *chan)
 {
 	int x;
@@ -2064,6 +2079,8 @@
 		/* Make sure we're not already open, a net device, or a slave device */
 		if (chans[unit]->flags & ZT_FLAG_OPEN) 
 			res = -EBUSY;
+		else if (chans[unit]->flags & ZT_FLAG_DEAD)
+			res = -EBUSY;
 		else if (chans[unit]->flags & ZT_FLAG_NETDEV)
 			res = -EBUSY;
 		else if (chans[unit]->master != chans[unit])
@@ -2131,7 +2148,7 @@
 	return pseudo;	
 }
 
-static void zt_free_pseudo(struct zt_chan *pseudo)
+static void __zt_free_pseudo(struct zt_chan *pseudo)
 {
 	if (pseudo) {
 		zt_chan_unreg(pseudo);
@@ -2139,6 +2156,18 @@
 	}
 }
 
+static void zt_free_pseudo(struct zt_chan *pseudo)
+{
+	long flags;
+	if (pseudo) {
+		/* Mark as dead for later reaping */
+		pseudo->flags |= ZT_FLAG_DEAD;
+		spin_lock_irqsave(&zapfreelock, flags);
+		zapneedfree = 1;
+		spin_unlock_irqrestore(&zapfreelock, flags);
+	}
+}
+
 static int zt_open(struct inode *inode, struct file *file)
 {
 	int unit = UNIT(file);
@@ -5845,6 +5874,18 @@
 				spin_unlock_irqrestore(&chans[x]->lock, flags);
 			}
 		}
+		spin_lock_irqsave(&zapfreelock, flags);
+		if (zapneedfree) {
+			/* Free any pseudos that might need it */
+			for (x=0;x<maxchans;x++) {
+				if (chans[x] && (chans[x]->flags & ZT_FLAG_DEAD)) {
+					__zt_free_pseudo(chans[x]);
+				}
+			}
+		}
+		__zt_recalc_maxchans();
+		spin_unlock_irqrestore(&zapfreelock, flags);
+
 	}
 #endif
 	return 0;

Index: zaptel.h
===================================================================
RCS file: /usr/cvsroot/zaptel/zaptel.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- zaptel.h	2 Jan 2004 23:28:52 -0000	1.25
+++ zaptel.h	6 Feb 2004 21:13:14 -0000	1.26
@@ -1111,6 +1111,7 @@
 #define ZT_FLAG_LINEAR			(1 << 13)	/* Talk to user space in linear */
 #define ZT_FLAG_PPP			(1 << 14)	/* PPP is available */
 #define ZT_FLAG_T1PPP			(1 << 15)
+#define ZT_FLAG_DEAD		(1 << 16)	/* Dead, needs to be removed */
 
 struct zt_span {
 	spinlock_t lock;




More information about the svn-commits mailing list