[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070320195914.12853.96917.stgit@warthog.cambridge.redhat.com>
Date: Tue, 20 Mar 2007 19:59:14 +0000
From: David Howells <dhowells@...hat.com>
To: davem@...emloft.net, netdev@...r.kernel.org, herbert.xu@...hat.com
Cc: linux-kernel@...r.kernel.org, hch@...radead.org,
arjan@...radead.org, dhowells@...hat.com
Subject: [PATCH 3/5] AF_RXRPC: Make it possible to merely try to cancel timers
and delayed work [try #3]
Export try_to_del_timer_sync() for use by the RxRPC module.
Add a try_to_cancel_delayed_work() so that it is possible to merely attempt to
cancel a delayed work timer.
Signed-Off-By: David Howells <dhowells@...hat.com>
---
include/linux/workqueue.h | 21 +++++++++++++++++++++
kernel/timer.c | 2 ++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 2a7b38d..40a61ae 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -204,4 +204,25 @@ static inline int cancel_delayed_work(struct delayed_work *work)
return ret;
}
+/**
+ * try_to_cancel_delayed_work - Try to kill pending scheduled, delayed work
+ * @work: the work to cancel
+ *
+ * Try to kill off a pending schedule_delayed_work().
+ * - The timer may still be running afterwards, and if so, the work may still
+ * be pending
+ * - Returns -1 if timer still active, 1 if timer removed, 0 if not scheduled
+ * - Can be called from the work routine; if it's still pending, just return
+ * and it'll be called again.
+ */
+static inline int try_to_cancel_delayed_work(struct delayed_work *work)
+{
+ int ret;
+
+ ret = try_to_del_timer_sync(&work->timer);
+ if (ret > 0)
+ work_release(&work->work);
+ return ret;
+}
+
#endif
diff --git a/kernel/timer.c b/kernel/timer.c
index 797cccb..447506a 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -505,6 +505,8 @@ out:
return ret;
}
+EXPORT_SYMBOL(try_to_del_timer_sync);
+
/**
* del_timer_sync - deactivate a timer and wait for the handler to finish.
* @timer: the timer to be deactivated
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists