diff options
author | Sander Vrijders <sander.vrijders@ugent.be> | 2017-03-25 18:48:30 +0100 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-03-25 18:48:30 +0100 |
commit | 572013b92d82e78ef5e5b19d79316ae3131c71af (patch) | |
tree | 43abd2084831d5a36c88a8ad93b3dec3e48127cd /src/ipcpd | |
parent | 6ccf4835a980122c5f411331600b57093035d18e (diff) | |
download | ouroboros-572013b92d82e78ef5e5b19d79316ae3131c71af.tar.gz ouroboros-572013b92d82e78ef5e5b19d79316ae3131c71af.zip |
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.
Diffstat (limited to 'src/ipcpd')
-rw-r--r-- | src/ipcpd/normal/graph.c | 14 | ||||
-rw-r--r-- | src/ipcpd/normal/routing.c | 4 |
2 files changed, 10 insertions, 8 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; } |