Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
lib/skiplist.c | 34 +++++++++++++++++++++++++++++++---
1 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/lib/skiplist.c b/lib/skiplist.c
index 30c3673..cf66d1e 100644
--- a/lib/skiplist.c
+++ b/lib/skiplist.c
@@ -267,12 +267,40 @@ skiplist_notify_del(qb_map_t * m, const char *key,
qb_map_notify_fn fn, int32_t events)
{
struct skiplist *t = (struct skiplist *)m;
- struct skiplist_node *n = skiplist_lookup(t, key);
+ struct skiplist_node *n;
+ struct qb_map_notifier *f;
+ struct qb_list_head *head = NULL;
+ struct qb_list_head *list;
+ struct qb_list_head *next;
+ int32_t found = QB_FALSE;
- if (n) {
+ if (key) {
+ n = skiplist_lookup(t, key);
+ if (n) {
+ head = &n->notifier_head;
+ }
+ } else {
+ head = &t->header->notifier_head;
+ }
+ if (head == NULL) {
+ return -ENOENT;
+ }
+ for (list = head->next;
+ list != head; list = next) {
+ f = qb_list_entry(list, struct qb_map_notifier, list);
+ next = list->next;
+
+ if (f->events == events && f->callback == fn) {
+ found = QB_TRUE;
+ qb_list_del(&f->list);
+ free(f);
+ }
+ }
+ if (found) {
return 0;
+ } else {
+ return -ENOENT;
}
- return -ENOENT;
}
static void
--
1.7.7.3