[Asterisk-cvs] zaptel zaptel.c,1.77,1.78

markster at lists.digium.com markster at lists.digium.com
Tue Jun 15 22:47:50 CDT 2004


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

Modified Files:
	zaptel.c 
Log Message:
Hold the big zap lock when allocating and freeing the pseudo channels


Index: zaptel.c
===================================================================
RCS file: /usr/cvsroot/zaptel/zaptel.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- zaptel.c	13 Jun 2004 16:34:45 -0000	1.77
+++ zaptel.c	16 Jun 2004 03:52:49 -0000	1.78
@@ -2137,6 +2137,7 @@
 static struct zt_chan *zt_alloc_pseudo(void)
 {
 	struct zt_chan *pseudo;
+	unsigned long flags;
 	/* Don't allow /dev/zap/pseudo to open if there are no spans */
 	if (maxspans < 1)
 		return NULL;
@@ -2147,18 +2148,23 @@
 	pseudo->sig = ZT_SIG_CLEAR;
 	pseudo->sigcap = ZT_SIG_CLEAR;
 	pseudo->flags = ZT_FLAG_PSEUDO | ZT_FLAG_AUDIO;
+	spin_lock_irqsave(&bigzaplock, flags);
 	if (zt_chan_reg(pseudo)) {
 		kfree(pseudo);
-		return NULL;
-	}
-	sprintf(pseudo->name, "Pseudo/%d", pseudo->channo);
+		pseudo = NULL;
+	} else
+		sprintf(pseudo->name, "Pseudo/%d", pseudo->channo);
+	spin_unlock_irqrestore(&bigzaplock, flags);
 	return pseudo;	
 }
 
 static void zt_free_pseudo(struct zt_chan *pseudo)
 {
+	unsigned long flags;
 	if (pseudo) {
+		spin_lock_irqsave(&bigzaplock, flags);
 		zt_chan_unreg(pseudo);
+		spin_unlock_irqrestore(&bigzaplock, flags);
 		kfree(pseudo);
 	}
 }




More information about the svn-commits mailing list