diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-09-09 13:50:47 +0200 |
---|---|---|
committer | Dimitri Staessens <dimitri.staessens@ugent.be> | 2017-09-12 08:33:26 -0600 |
commit | 45c6615484ffe347654c34decb72ff1ef9bde0f3 (patch) | |
tree | f912e0eef256371f61b87a5a78e7604d9b623194 /src/ipcpd/normal/dht.c | |
parent | 7c69c0f6b25a199bb3632eea66ccb7de1db06ccc (diff) | |
download | ouroboros-45c6615484ffe347654c34decb72ff1ef9bde0f3.tar.gz ouroboros-45c6615484ffe347654c34decb72ff1ef9bde0f3.zip |
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.
Diffstat (limited to 'src/ipcpd/normal/dht.c')
-rw-r--r-- | src/ipcpd/normal/dht.c | 14 |
1 files changed, 7 insertions, 7 deletions
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: |