diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2020-12-14 17:27:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-14 17:27:55 +0300 |
commit | 0f8175dd3060691394e263cdab01c8f940b1b5d3 (patch) | |
tree | 4b14cd6b7e6ba7797eeec4c74b4c4c35cdad4494 /libnetdata/avl | |
parent | 7bfa8c8eba72a109d940b1fa5c7acaed9cd7a52c (diff) |
Kubernetes labels (#10107)
Co-authored-by: Markos Fountoulakis <markos.fountoulakis.senior@gmail.com>
Co-authored-by: Vladimir Kobal <vlad@prokk.net>
Diffstat (limited to 'libnetdata/avl')
-rw-r--r-- | libnetdata/avl/avl.c | 16 | ||||
-rw-r--r-- | libnetdata/avl/avl.h | 3 |
2 files changed, 19 insertions, 0 deletions
diff --git a/libnetdata/avl/avl.c b/libnetdata/avl/avl.c index 15293740d4..5219851896 100644 --- a/libnetdata/avl/avl.c +++ b/libnetdata/avl/avl.c @@ -367,6 +367,22 @@ void avl_init_lock(avl_tree_lock *tree, int (*compar)(void * /*a*/, void * /*b*/ #endif /* AVL_WITHOUT_PTHREADS */ } +void avl_destroy_lock(avl_tree_lock *tree) { +#ifndef AVL_WITHOUT_PTHREADS + int lock; + +#ifdef AVL_LOCK_WITH_MUTEX + lock = pthread_mutex_destroy(&tree->mutex); +#else + lock = pthread_rwlock_destroy(&tree->rwlock); +#endif + + if(lock != 0) + fatal("Failed to destroy AVL mutex/rwlock, error: %d", lock); + +#endif /* AVL_WITHOUT_PTHREADS */ +} + avl *avl_search_lock(avl_tree_lock *tree, avl *item) { avl_read_lock(tree); avl *ret = avl_search(&tree->avl_tree, item); diff --git a/libnetdata/avl/avl.h b/libnetdata/avl/avl.h index a3e0f65667..32e3f27a8b 100644 --- a/libnetdata/avl/avl.h +++ b/libnetdata/avl/avl.h @@ -82,6 +82,9 @@ avl *avl_search(avl_tree_type *tree, avl *item); void avl_init_lock(avl_tree_lock *tree, int (*compar)(void *a, void *b)); void avl_init(avl_tree_type *tree, int (*compar)(void *a, void *b)); +/* Destroy the avl_tree_lock locks + */ +void avl_destroy_lock(avl_tree_lock *tree); int avl_traverse_lock(avl_tree_lock *tree, int (*callback)(void *entry, void *data), void *data); int avl_traverse(avl_tree_type *tree, int (*callback)(void *entry, void *data), void *data); |