summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_timeout.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2005-09-08 14:20:39 +0000
committerglebius <glebius@FreeBSD.org>2005-09-08 14:20:39 +0000
commit8f3eb2a42516bd9997f65e3756ab112b9c4d1f77 (patch)
tree28d972cf1fcd2514ba5a8b5fca4778e5e77c5548 /sys/kern/kern_timeout.c
parent28cd9f962898edb79beaf6cde6cdd90a29cbc061 (diff)
downloadFreeBSD-src-8f3eb2a42516bd9997f65e3756ab112b9c4d1f77.zip
FreeBSD-src-8f3eb2a42516bd9997f65e3756ab112b9c4d1f77.tar.gz
Make callout_reset() return a non-zero value if a pending callout
was rescheduled. If there was no pending callout, then return 0. Reviewed by: iedowse, cperciva
Diffstat (limited to 'sys/kern/kern_timeout.c')
-rw-r--r--sys/kern/kern_timeout.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
index f2fafbb..8e6b183 100644
--- a/sys/kern/kern_timeout.c
+++ b/sys/kern/kern_timeout.c
@@ -427,13 +427,14 @@ callout_handle_init(struct callout_handle *handle)
* callout_pending() - returns truth if callout is still waiting for timeout
* callout_deactivate() - marks the callout as having been serviced
*/
-void
+int
callout_reset(c, to_ticks, ftn, arg)
struct callout *c;
int to_ticks;
void (*ftn)(void *);
void *arg;
{
+ int cancelled = 0;
#ifdef notyet /* Some callers of timeout() do not hold Giant. */
if (c->c_mtx != NULL)
@@ -448,14 +449,14 @@ callout_reset(c, to_ticks, ftn, arg)
* can cancel the callout if it has not really started.
*/
if (c->c_mtx != NULL && !curr_cancelled)
- curr_cancelled = 1;
+ cancelled = curr_cancelled = 1;
if (wakeup_needed) {
/*
* Someone has called callout_drain to kill this
* callout. Don't reschedule.
*/
mtx_unlock_spin(&callout_lock);
- return;
+ return (cancelled);
}
}
if (c->c_flags & CALLOUT_PENDING) {
@@ -465,6 +466,8 @@ callout_reset(c, to_ticks, ftn, arg)
TAILQ_REMOVE(&callwheel[c->c_time & callwheelmask], c,
c_links.tqe);
+ cancelled = 1;
+
/*
* Part of the normal "stop a pending callout" process
* is to clear the CALLOUT_ACTIVE and CALLOUT_PENDING
@@ -490,6 +493,8 @@ callout_reset(c, to_ticks, ftn, arg)
TAILQ_INSERT_TAIL(&callwheel[c->c_time & callwheelmask],
c, c_links.tqe);
mtx_unlock_spin(&callout_lock);
+
+ return (cancelled);
}
int
OpenPOWER on IntegriCloud