summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2018-10-11 15:56:24 +0200
committerDimitri Staessens <dimitri.staessens@ugent.be>2018-10-11 20:25:43 +0200
commit558fc46c63d28ce2ffd0abc5c737f49cc185ba82 (patch)
tree4dbcfe64b25fa5912fc5dc27024df6d2c5bf2de7 /src/lib
parentca22ee6c603d3a03cca902d302f4c25e1f5b003e (diff)
downloadouroboros-558fc46c63d28ce2ffd0abc5c737f49cc185ba82.tar.gz
ouroboros-558fc46c63d28ce2ffd0abc5c737f49cc185ba82.zip
lib: Add cleanup function in notifier
This adds a cleanup function in the notifier in case it gets cancelled, which is a possibility in some callbacks. Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be> Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/notifier.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/notifier.c b/src/lib/notifier.c
index 593a0e70..4f77f2e3 100644
--- a/src/lib/notifier.c
+++ b/src/lib/notifier.c
@@ -75,12 +75,15 @@ void notifier_event(int event,
pthread_rwlock_rdlock(&notifier.lock);
+ pthread_cleanup_push((void (*) (void *)) pthread_rwlock_unlock,
+ (void *) &notifier.lock)
+
list_for_each(p, &notifier.listeners) {
struct listener * l = list_entry(p, struct listener, next);
l->callback(l->obj, event, o);
}
- pthread_rwlock_unlock(&notifier.lock);
+ pthread_cleanup_pop(true);
}
int notifier_reg(notifier_fn_t callback,