[zaptel-commits] mattf: trunk r1603 - /trunk/zaptel.c

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Thu Nov 16 16:09:21 MST 2006


Author: mattf
Date: Thu Nov 16 17:09:21 2006
New Revision: 1603

URL: http://svn.digium.com/view/zaptel?view=rev&rev=1603
Log:
Fix for 7769.  Make sure we lock before modifying flags.

Modified:
    trunk/zaptel.c

Modified: trunk/zaptel.c
URL: http://svn.digium.com/view/zaptel/trunk/zaptel.c?view=diff&rev=1603&r1=1602&r2=1603
==============================================================================
--- trunk/zaptel.c (original)
+++ trunk/zaptel.c Thu Nov 16 17:09:21 2006
@@ -2347,8 +2347,10 @@
 		else if ((chans[unit]->sig & __ZT_SIG_DACS) == __ZT_SIG_DACS)
 			res = -EBUSY;
 		else {
+			unsigned long flags;
 			/* Assume everything is going to be okay */
 			res = initialize_channel(chans[unit]);
+			spin_lock_irqsave(&chans[unit]->lock, flags);
 			if (chans[unit]->flags & ZT_FLAG_PSEUDO) 
 				chans[unit]->flags |= ZT_FLAG_AUDIO;
 			if (chans[unit]->span && chans[unit]->span->open)
@@ -2360,7 +2362,9 @@
 					MOD_INC_USE_COUNT;
 #endif					
 				chans[unit]->flags |= ZT_FLAG_OPEN;
+				spin_unlock_irqrestore(&chans[unit]->lock, flags);
 			} else {
+				spin_unlock_irqrestore(&chans[unit]->lock, flags);
 				close_channel(chans[unit]);
 			}
 		}
@@ -2373,7 +2377,10 @@
 {
 	int res=0;
 	if (chans[unit]) {
+		unsigned long flags;
+		spin_lock_irqsave(&chans[unit]->lock, flags);
 		chans[unit]->flags &= ~ZT_FLAG_OPEN;
+		spin_unlock_irqrestore(&chans[unit]->lock, flags);
 		chans[unit]->file = NULL;
 		close_channel(chans[unit]);
 		if (chans[unit]->span && chans[unit]->span->close)



More information about the zaptel-commits mailing list