From 4c9b3db27ac2c4f98ca16ad326c367653d97bfef Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Thu, 30 Mar 2017 22:22:33 +0200 Subject: ipcpd: Add missing lock in normal/neighbors --- src/ipcpd/normal/neighbors.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ipcpd/normal/neighbors.c b/src/ipcpd/normal/neighbors.c index d50732cb..f52a2319 100644 --- a/src/ipcpd/normal/neighbors.c +++ b/src/ipcpd/normal/neighbors.c @@ -40,12 +40,16 @@ static void notify_listeners(enum nb_event event, { struct list_head * p = NULL; + pthread_mutex_lock(&nbs->notifiers_lock); + list_for_each(p, &nbs->notifiers) { struct nb_notifier * e = list_entry(p, struct nb_notifier, next); if (e->notify_call(event, nb->conn)) log_err("Listener reported an error."); } + + pthread_mutex_unlock(&nbs->notifiers_lock); } struct nbs * nbs_create(void) @@ -106,8 +110,6 @@ int nbs_add(struct nbs * nbs, nb->conn = conn; - list_head_init(&nb->next); - pthread_mutex_lock(&nbs->list_lock); list_add(&nb->next, &nbs->list); @@ -183,7 +185,6 @@ int nbs_reg_notifier(struct nbs * nbs, pthread_mutex_lock(&nbs->notifiers_lock); - list_head_init(¬ify->next); list_add(¬ify->next, &nbs->notifiers); pthread_mutex_unlock(&nbs->notifiers_lock); -- cgit v1.2.3