[dahdi-commits] sruffell: linux/trunk r9937 - /linux/trunk/drivers/dahdi/dahdi-base.c

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Thu Jun 2 15:01:24 CDT 2011


Author: sruffell
Date: Thu Jun  2 15:01:20 2011
New Revision: 9937

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9937
Log:
dahdi: If a timer is not configured then we should block indefinitely.

Some older Asterisk versions do not handle well the error message when poll is
called on an unconfigured channel. The result would be constant

__ast_read: No/unknown event '0' on timer for 'DAHDI/1-1'?

messages from Asterisk.

Signed-off-by: Shaun Ruffell <sruffell at digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

Modified:
    linux/trunk/drivers/dahdi/dahdi-base.c

Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=9937&r1=9936&r2=9937
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Thu Jun  2 15:01:20 2011
@@ -8617,13 +8617,39 @@
 	spin_unlock(&dahdi_timer_lock);
 }
 
-static unsigned int dahdi_timer_poll(struct file *file, struct poll_table_struct *wait_table)
+/**
+ * dahdi_timer_poll - Poll function for a dahdi_timer.
+ * @file:	Open timer handle.
+ * @wait_table: Just passing through...
+ *
+ * Returns 0 if there isn't anything to wake us up, otherwise POLLPRI if there
+ * is an event waiting on the timer.
+ *
+ * Older versions of Asterisk depend on the behavior that this poll will block
+ * indefintely if the timer has not been configured, so if there is no rate
+ * attached to the timer, this function must return 0.
+ *
+ */
+static unsigned int
+dahdi_timer_poll(struct file *file, struct poll_table_struct *wait_table)
 {
 	struct dahdi_timer *timer = file->private_data;
-	struct dahdi_timer_rate *rate = timer->rate;
-
-	if (!rate || !timer)
+	struct dahdi_timer_rate *rate;
+
+	if (!timer)
 		return -EINVAL;
+
+	rate = timer->rate;
+
+	if (!rate) {
+		static bool __once;
+		if (!__once) {
+			__once = true;
+			module_printk(KERN_NOTICE,
+				      "Calling poll on unconfigured timer.\n");
+		}
+		return 0;
+	}
 
 	poll_wait(file, &rate->sel, wait_table);
 	if (atomic_read(&timer->tripped) || atomic_read(&timer->ping))




More information about the dahdi-commits mailing list