diff options
author | glebius <glebius@FreeBSD.org> | 2004-11-02 21:24:30 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2004-11-02 21:24:30 +0000 |
commit | a033067901d630caa7ecc38fcf8a0d416a4b6d3d (patch) | |
tree | a65f34c1266b3b9307271ab695db1b77e0055c9e /sys/netgraph/ng_base.c | |
parent | 8b6661b126d65e1e6be9c505085ca230e7f42f01 (diff) | |
download | FreeBSD-src-a033067901d630caa7ecc38fcf8a0d416a4b6d3d.zip FreeBSD-src-a033067901d630caa7ecc38fcf8a0d416a4b6d3d.tar.gz |
- Make ng_timeout() to use callout() interface instead of timeout().
- Remove callout-hacking from ng_untimeout().
Approved by: julian (mentor)
MFC after: 1 month
Diffstat (limited to 'sys/netgraph/ng_base.c')
-rw-r--r-- | sys/netgraph/ng_base.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index 601ac9b..c06e830 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -3595,17 +3595,15 @@ ng_timeout_trapoline(void *arg) } -struct callout_handle -ng_timeout(node_p node, hook_p hook, int ticks, +int +ng_timeout(struct callout *c, node_p node, hook_p hook, int ticks, ng_item_fn *fn, void * arg1, int arg2) { item_p item; - if ((item = ng_getqblk()) == NULL) { - struct callout_handle handle; - handle.callout = NULL; - return (handle); - } + if ((item = ng_getqblk()) == NULL) + return (ENOMEM); + item->el_flags = NGQF_FN | NGQF_WRITER; NG_NODE_REF(node); /* and one for the item */ NGI_SET_NODE(item, node); @@ -3616,33 +3614,33 @@ ng_timeout(node_p node, hook_p hook, int ticks, NGI_FN(item) = fn; NGI_ARG1(item) = arg1; NGI_ARG2(item) = arg2; - return (timeout(&ng_timeout_trapoline, item, ticks)); + callout_reset(c, ticks, &ng_timeout_trapoline, item); + return (0); } /* A special modified version of untimeout() */ int -ng_untimeout(struct callout_handle handle, node_p node) +ng_untimeout(struct callout *c, node_p node) { item_p item; + int rval; - if (handle.callout == NULL) + if (c == NULL) return (0); - mtx_lock_spin(&callout_lock); - item = handle.callout->c_arg; /* should be an official way to do this */ - if ((handle.callout->c_func == &ng_timeout_trapoline) && - (NGI_NODE(item) == node) && - (callout_stop(handle.callout))) { + rval = callout_drain(c); + item = c->c_arg; + /* Do an extra check */ + if ((c->c_func == &ng_timeout_trapoline) && + (NGI_NODE(item) == node)) { /* * We successfully removed it from the queue before it ran * So now we need to unreference everything that was * given extra references. (NG_FREE_ITEM does this). */ - mtx_unlock_spin(&callout_lock); NG_FREE_ITEM(item); - return (1); } - mtx_unlock_spin(&callout_lock); - return (0); + + return (rval); } /* |