summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-09-19 16:48:54 +0000
committerSander Vrijders <sander.vrijders@ugent.be>2017-09-19 16:48:54 +0000
commitacd8235533d63a7e4dd4d1b5bdb17423d4b6fd75 (patch)
tree195bbf3a1aa1923394410db072f72c0b38aede8c /src/lib
parentc0bbd7e2184f51038ecbaebfa3b21e5c52d35239 (diff)
parent1dcef3957393c0500b81d93ffacf573e78be9a51 (diff)
downloadouroboros-acd8235533d63a7e4dd4d1b5bdb17423d4b6fd75.tar.gz
ouroboros-acd8235533d63a7e4dd4d1b5bdb17423d4b6fd75.zip
Merged in dstaesse/ouroboros/be-dht-async (pull request #598)
ipcpd: Enroll DHT when creating dt connection
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/notifier.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/notifier.c b/src/lib/notifier.c
index cfd383d4..5c38cf58 100644
--- a/src/lib/notifier.c
+++ b/src/lib/notifier.c
@@ -30,6 +30,7 @@
struct listener {
struct list_head next;
notifier_fn_t callback;
+ void * obj;
};
struct {
@@ -72,13 +73,16 @@ void notifier_event(int event,
pthread_mutex_lock(&notifier.lock);
- list_for_each(p, &notifier.listeners)
- list_entry(p, struct listener, next)->callback(event, o);
+ list_for_each(p, &notifier.listeners) {
+ struct listener * l = list_entry(p, struct listener, next);
+ l->callback(l->obj, event, o);
+ }
pthread_mutex_unlock(&notifier.lock);
}
-int notifier_reg(notifier_fn_t callback)
+int notifier_reg(notifier_fn_t callback,
+ void * obj)
{
struct listener * l;
struct list_head * p;
@@ -100,8 +104,9 @@ int notifier_reg(notifier_fn_t callback)
}
l->callback = callback;
+ l->obj = obj;
- list_add(&l->next, &notifier.listeners);
+ list_add_tail(&l->next, &notifier.listeners);
pthread_mutex_unlock(&notifier.lock);