[zaptel-commits] tzafrir: branch tzafrir/makefile r1476 - in /team/tzafrir/makefile: ./ zaptel.c

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Sun Sep 24 14:16:19 MST 2006


Author: tzafrir
Date: Sun Sep 24 16:16:19 2006
New Revision: 1476

URL: http://svn.digium.com/view/zaptel?rev=1476&view=rev
Log:
Sync to branches/1.4 (rev 1462-1371) . white-space damage included.

Modified:
    team/tzafrir/makefile/   (props changed)
    team/tzafrir/makefile/zaptel.c

Propchange: team/tzafrir/makefile/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Modified: team/tzafrir/makefile/zaptel.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/makefile/zaptel.c?rev=1476&r1=1475&r2=1476&view=diff
==============================================================================
--- team/tzafrir/makefile/zaptel.c (original)
+++ team/tzafrir/makefile/zaptel.c Sun Sep 24 16:16:19 2006
@@ -1154,8 +1154,21 @@
 	/* Assumes channel is already locked */
 	if ((zone >= ZT_TONE_ZONE_MAX) || (zone < -1))
 		return -EINVAL;
-	
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+	/* Since this routine is called both from IRQ as well as from userspace,
+	 * it is possible that we could be called during an IRQ while userspace
+	 * has locked this.  However unlikely, this could possibly cause a
+	 * deadlock. */
+	if (! read_trylock(&zone_lock))
+		return -EWOULDBLOCK;
+#else
+	/* But there are no trylock macros for kernel versions before 2.6.11,
+	 * so we do the unsafe thing anyway.  Such is the problem for dealing
+	 * with old, buggy kernels. */
 	read_lock(&zone_lock);
+#endif
+
 	if (zone == -1) {
 		zone = default_zone;
 	}
@@ -1166,7 +1179,7 @@
 	} else {
 		res = -ENODATA;
 	}
-	
+
 	read_unlock(&zone_lock);
 	return res;
 }



More information about the zaptel-commits mailing list