From 45c6615484ffe347654c34decb72ff1ef9bde0f3 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Sat, 9 Sep 2017 13:50:47 +0200 Subject: ipcpd: Revise internals of normal IPCP This removes the RIB as a datastructure and CDAP as the protocol between IPCPs. CDAP, the rib and related sources are deprecated. The link-state protocol policy is udpated to use its own protocol based on a simple broadcast strategy along a tree. The neighbors struct is deprecated and moved to the library as a generic notifier component. --- src/ipcpd/normal/dht.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/ipcpd/normal/dht.c') diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c index d139cb91..b1ba44a8 100644 --- a/src/ipcpd/normal/dht.c +++ b/src/ipcpd/normal/dht.c @@ -328,9 +328,6 @@ static void kad_req_destroy(struct kad_req * req) { assert(req); - if (req->key != NULL) - free(req->key); - pthread_mutex_lock(&req->lock); switch (req->state) { @@ -351,7 +348,7 @@ static void kad_req_destroy(struct kad_req * req) break; } - while (req->state != REQ_NULL) + while (req->state != REQ_NULL && req->state != REQ_DONE) pthread_cond_wait(&req->cond, &req->lock); pthread_mutex_unlock(&req->lock); @@ -359,6 +356,9 @@ static void kad_req_destroy(struct kad_req * req) pthread_cond_destroy(&req->cond); pthread_mutex_destroy(&req->lock); + if (req->key != NULL) + free(req->key); + free(req); } @@ -391,7 +391,7 @@ static int kad_req_wait(struct kad_req * req, case REQ_PENDING: /* ETIMEDOUT */ case REQ_RESPONSE: req->state = REQ_DONE; - pthread_cond_signal(&req->cond); + pthread_cond_broadcast(&req->cond); break; default: break; @@ -1859,7 +1859,7 @@ static void * work(void * o) if (now.tv_sec > v->t_exp) { list_del(&v->next); val_destroy(v); - } + } if (now.tv_sec > v->t_rep) { kad_publish(dht, e->key, v->addr, @@ -2018,7 +2018,7 @@ static void kad_handle_response(struct dht * dht, case KAD_FIND_VALUE: case KAD_FIND_NODE: if (dht_get_state(dht) != DHT_RUNNING) - return; + break; kad_handle_find_resp(dht, req, msg); break; default: -- cgit v1.2.3