summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_base.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2004-11-04 21:30:18 +0000
committerglebius <glebius@FreeBSD.org>2004-11-04 21:30:18 +0000
commit72e8effbe5cdc67c4f399cc9a1768eb77b95d660 (patch)
tree1890bfa1c01bfe6307a355b57d66e9ff3ca3ea78 /sys/netgraph/ng_base.c
parent65c874982c1e196f5c8bfb5d51585c90d8af7865 (diff)
downloadFreeBSD-src-72e8effbe5cdc67c4f399cc9a1768eb77b95d660.zip
FreeBSD-src-72e8effbe5cdc67c4f399cc9a1768eb77b95d660.tar.gz
Partically backout previous commit. Since _callout_stop_safe() clears
out c->c_func, we can't take it after callout_stop(). To take it before we need to acquire callout_lock, to avoid race. This commit narrows down area where lock is held, but hack is still present. This should be redesigned. Approved by: julian (mentor)
Diffstat (limited to 'sys/netgraph/ng_base.c')
-rw-r--r--sys/netgraph/ng_base.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c
index c06e830..5c36480 100644
--- a/sys/netgraph/ng_base.c
+++ b/sys/netgraph/ng_base.c
@@ -3624,13 +3624,18 @@ ng_untimeout(struct callout *c, node_p node)
{
item_p item;
int rval;
+ void *c_func;
if (c == NULL)
return (0);
- rval = callout_drain(c);
+ /* there must be an official way to do this */
+ mtx_lock_spin(&callout_lock);
+ c_func = c->c_func;
+ rval = callout_stop(c);
+ mtx_unlock_spin(&callout_lock);
item = c->c_arg;
/* Do an extra check */
- if ((c->c_func == &ng_timeout_trapoline) &&
+ if ((rval > 0) && (c_func == &ng_timeout_trapoline) &&
(NGI_NODE(item) == node)) {
/*
* We successfully removed it from the queue before it ran
OpenPOWER on IntegriCloud