summaryrefslogtreecommitdiff
path: root/drivers/dahdi/dahdi-base.c
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2011-06-02 20:01:20 +0000
committerShaun Ruffell <sruffell@digium.com>2011-06-02 20:01:20 +0000
commitd47c063f42197ae1aa59a8f8512a4b52cb611aff (patch)
tree90748590f905b3f8c16fe5ecc62f7b0a8811c662 /drivers/dahdi/dahdi-base.c
parentc659b9f900fc91cbb3269ab907f15b52c26b252f (diff)
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@digium.com> Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9937 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/dahdi-base.c')
-rw-r--r--drivers/dahdi/dahdi-base.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index a9cd775..2a5d6f9 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -8617,14 +8617,40 @@ static void process_timers(void)
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;
+ struct dahdi_timer_rate *rate;
- if (!rate || !timer)
+ 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))
return POLLPRI;