diff options
author | glebius <glebius@FreeBSD.org> | 2011-07-04 07:03:44 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2011-07-04 07:03:44 +0000 |
commit | ffb5cf471446f18c2ed162926526b1930bfa572b (patch) | |
tree | c636f50c30142b8d254242bb07d18e28e30a26eb /sys/netgraph/netgraph.h | |
parent | 766eac763608b17c9277e49469f5f329f4a16332 (diff) | |
download | FreeBSD-src-ffb5cf471446f18c2ed162926526b1930bfa572b.zip FreeBSD-src-ffb5cf471446f18c2ed162926526b1930bfa572b.tar.gz |
- Use refcount(9) API to manage node and hook refcounting.
- Make ng_unref_node() void, since caller shouldn't be
interested in whether node is valid after call or not,
since it can't be guaranteed to be valid. [1]
Ok from: julian [1]
Diffstat (limited to 'sys/netgraph/netgraph.h')
-rw-r--r-- | sys/netgraph/netgraph.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h index 8dbf0b5..51fe440 100644 --- a/sys/netgraph/netgraph.h +++ b/sys/netgraph/netgraph.h @@ -53,6 +53,7 @@ #include <sys/malloc.h> #include <sys/module.h> #include <sys/mutex.h> +#include <sys/refcount.h> #ifdef HAVE_KERNEL_OPTION_HEADERS #include "opt_netgraph.h" @@ -137,7 +138,7 @@ struct ng_hook { * If you can't do it with these you probably shouldn;t be doing it. */ void ng_unref_hook(hook_p hook); /* don't move this */ -#define _NG_HOOK_REF(hook) atomic_add_int(&(hook)->hk_refs, 1) +#define _NG_HOOK_REF(hook) refcount_acquire(&(hook)->hk_refs) #define _NG_HOOK_NAME(hook) ((hook)->hk_name) #define _NG_HOOK_UNREF(hook) ng_unref_hook(hook) #define _NG_HOOK_SET_PRIVATE(hook, val) do {(hook)->hk_private = val;} while (0) @@ -396,11 +397,11 @@ struct ng_node { * Public methods for nodes. * If you can't do it with these you probably shouldn't be doing it. */ -int ng_unref_node(node_p node); /* don't move this */ +void ng_unref_node(node_p node); /* don't move this */ #define _NG_NODE_NAME(node) ((node)->nd_name + 0) #define _NG_NODE_HAS_NAME(node) ((node)->nd_name[0] + 0) #define _NG_NODE_ID(node) ((node)->nd_ID + 0) -#define _NG_NODE_REF(node) atomic_add_int(&(node)->nd_refs, 1) +#define _NG_NODE_REF(node) refcount_acquire(&(node)->nd_refs) #define _NG_NODE_UNREF(node) ng_unref_node(node) #define _NG_NODE_SET_PRIVATE(node, val) do {(node)->nd_private = val;} while (0) #define _NG_NODE_PRIVATE(node) ((node)->nd_private) |