From 6ccf4835a980122c5f411331600b57093035d18e Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Sat, 25 Mar 2017 13:16:11 +0100 Subject: ipcpd: normal: Fix compilation issue --- src/ipcpd/normal/fmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c index d2966d0c..a8a9ba58 100644 --- a/src/ipcpd/normal/fmgr.c +++ b/src/ipcpd/normal/fmgr.c @@ -494,7 +494,7 @@ int fmgr_np1_alloc(int fd, return -1; } - free(buf->data); + free(buf.data); fmgr.np1_fd_to_cep_id[fd] = cep_id; fmgr.np1_cep_id_to_fd[cep_id] = fd; -- cgit v1.2.3 From 572013b92d82e78ef5e5b19d79316ae3131c71af Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Sat, 25 Mar 2017 18:48:30 +0100 Subject: lib, ipcpd: Fix bugs in ro sets This fixes several bugs in the ro sets, rib. And it fixes several bugs in the graph and routing component of the normal IPCP. --- src/ipcpd/normal/graph.c | 14 ++++++++------ src/ipcpd/normal/routing.c | 4 ++-- src/lib/rib.c | 10 +++++++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/ipcpd/normal/graph.c b/src/ipcpd/normal/graph.c index b3e105e3..272576bb 100644 --- a/src/ipcpd/normal/graph.c +++ b/src/ipcpd/normal/graph.c @@ -106,15 +106,15 @@ static void del_edge(struct edge * edge) free(edge); } -static int add_vertex(struct graph * graph, - uint64_t addr) +static struct vertex * add_vertex(struct graph * graph, + uint64_t addr) { struct vertex * vertex; struct list_head * p; vertex = malloc(sizeof(*vertex)); if (vertex == NULL) - return -1; + return NULL; list_head_init(&vertex->next); list_head_init(&vertex->edges); @@ -130,7 +130,7 @@ static int add_vertex(struct graph * graph, graph->nr_vertices++; - return 0; + return vertex; } static void del_vertex(struct graph * graph, @@ -206,7 +206,8 @@ int graph_add_edge(struct graph * graph, v = find_vertex_by_addr(graph, s_addr); if (v == NULL) { - if (add_vertex(graph, s_addr)) { + v = add_vertex(graph, s_addr); + if (v == NULL) { pthread_mutex_unlock(&graph->lock); return -ENOMEM; } @@ -221,7 +222,8 @@ int graph_add_edge(struct graph * graph, nb = find_vertex_by_addr(graph, d_addr); if (nb == NULL) { - if (add_vertex(graph, d_addr)) { + nb = add_vertex(graph, d_addr); + if (nb == NULL) { pthread_mutex_unlock(&graph->lock); return -ENOMEM; } diff --git a/src/ipcpd/normal/routing.c b/src/ipcpd/normal/routing.c index b750ca84..998b294a 100644 --- a/src/ipcpd/normal/routing.c +++ b/src/ipcpd/normal/routing.c @@ -291,12 +291,12 @@ static void * rib_listener(void * o) } } - while (rib_event_wait(routing.set, routing.queue, NULL)) { + while (rib_event_wait(routing.set, routing.queue, NULL) == 0) { flag = rqueue_next(routing.queue, path); if (flag < 0) continue; - if (read_fso(children[i], flag)) { + if (read_fso(path, flag)) { log_err("Failed to parse FSO."); continue; } diff --git a/src/lib/rib.c b/src/lib/rib.c index 8468e88c..fc58f266 100644 --- a/src/lib/rib.c +++ b/src/lib/rib.c @@ -177,6 +177,8 @@ static struct revent * revent_dup(struct revent * ev) re->flags = ev->flags; + list_head_init(&re->next); + return re; } @@ -196,7 +198,13 @@ static void rnode_notify_subs(struct rnode * node, struct rn_sub * s = list_entry(p, struct rn_sub, next); if (s->flags & ev->flags) { struct revent * e = revent_dup(ev); + if (e == NULL) + continue; + + pthread_mutex_lock(&s->sub->lock); list_add_tail(&e->next, &s->sub->events); + pthread_cond_signal(&s->sub->cond); + pthread_mutex_unlock(&s->sub->lock); } if (ev->flags & RO_DELETE) @@ -1130,7 +1138,7 @@ int rib_event_wait(ro_set_t * set, while (list_is_empty(&sub->events) && ret != -ETIMEDOUT) { if (timeout != NULL) - ret = -pthread_cond_timedwait(&sub->cond , + ret = -pthread_cond_timedwait(&sub->cond, &sub->lock, &abstime); else -- cgit v1.2.3