From: David Howells <dhowells@redhat.com>
To: davem@davemloft.net, netdev@vger.kernel.org, herbert.xu@redhat.com
Cc: linux-kernel@vger.kernel.org, hch@infradead.org,
arjan@infradead.org, dhowells@redhat.com
Subject: [PATCH 3/5] AF_RXRPC: Make it possible to merely try to cancel timers and delayed work
Date: Thu, 08 Mar 2007 22:48:54 +0000 [thread overview]
Message-ID: <20070308224854.17456.71874.stgit@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <20070308224806.17456.13944.stgit@warthog.cambridge.redhat.com>
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@redhat.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
next prev parent reply other threads:[~2007-03-08 22:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-08 22:48 [PATCH 0/5] [RFC] AF_RXRPC socket family implementation David Howells
2007-03-08 22:48 ` [PATCH 1/5] AF_RXRPC: Add blkcipher accessors for using kernel data directly David Howells
2007-03-08 22:55 ` Valdis.Kletnieks
2007-03-08 22:48 ` [PATCH 2/5] AF_RXRPC: Move generic skbuff stuff from XFRM code to generic code David Howells
2007-03-08 22:48 ` David Howells [this message]
2007-03-08 22:49 ` [PATCH 4/5] AF_RXRPC: Key facility changes for AF_RXRPC David Howells
2007-03-08 22:54 ` [PATCH 0/5] [RFC] AF_RXRPC socket family implementation David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070308224854.17456.71874.stgit@warthog.cambridge.redhat.com \
--to=dhowells@redhat.com \
--cc=arjan@infradead.org \
--cc=davem@davemloft.net \
--cc=hch@infradead.org \
--cc=herbert.xu@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).