diff options
author | Thomas Haller <thaller@redhat.com> | 2022-03-15 11:41:50 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-03-16 23:09:27 (GMT) |
commit | 2e0d7f85d2aeed9181a276079b5a28cc1c8e90ac (patch) | |
tree | 44b8862ed14661a0553a3c7abb67d150d69463b4 /lib/route | |
parent | e8842867b16419cbef8078da9e9714cac32b74af (diff) | |
download | libnl-2e0d7f85d2aeed9181a276079b5a28cc1c8e90ac.zip libnl-2e0d7f85d2aeed9181a276079b5a28cc1c8e90ac.tar.gz libnl-2e0d7f85d2aeed9181a276079b5a28cc1c8e90ac.tar.bz2 |
lib: add rtnl_link_info_ops_get() and take lock for rtnl_link_info_ops's io_refcnt
Diffstat (limited to 'lib/route')
-rw-r--r-- | lib/route/link/api.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/route/link/api.c b/lib/route/link/api.c index 23951fa..8bbe3d9 100644 --- a/lib/route/link/api.c +++ b/lib/route/link/api.c @@ -81,13 +81,31 @@ struct rtnl_link_info_ops *rtnl_link_info_ops_lookup(const char *name) } /** + * Take reference to a set of operations. + * @arg ops Link info operations. + */ +void rtnl_link_info_ops_get(struct rtnl_link_info_ops *ops) +{ + if (!ops) + return; + + nl_write_lock(&info_lock); + ops->io_refcnt++; + nl_write_unlock(&info_lock); +} + +/** * Give back reference to a set of operations. * @arg ops Link info operations. */ void rtnl_link_info_ops_put(struct rtnl_link_info_ops *ops) { - if (ops) - ops->io_refcnt--; + if (!ops) + return; + + nl_write_lock(&info_lock); + ops->io_refcnt--; + nl_write_unlock(&info_lock); } /** |