diff options
author | Sander Vrijders <[email protected]> | 2018-01-25 11:48:49 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2018-01-25 11:48:49 +0100 |
commit | 7738a4c41193dc9a3b5a1eb2d88e54c00ba191ed (patch) | |
tree | b90738fa0c9b391fdc091d3b3458ae0a4532ab17 /src | |
parent | 0091e229c288bfd580f36fbc9e6224a0e38f860e (diff) | |
parent | 803185fc973aebb5a24bf08f4cb4d8a3d3e96d16 (diff) | |
download | ouroboros-7738a4c41193dc9a3b5a1eb2d88e54c00ba191ed.tar.gz ouroboros-7738a4c41193dc9a3b5a1eb2d88e54c00ba191ed.zip |
Merge branch 'testing' into be
Diffstat (limited to 'src')
-rw-r--r-- | src/ipcpd/normal/dht.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c index a59b7781..103ffd1c 100644 --- a/src/ipcpd/normal/dht.c +++ b/src/ipcpd/normal/dht.c @@ -72,9 +72,9 @@ typedef KadContactMsg kad_contact_msg_t; enum dht_state { DHT_INIT = 0, + DHT_SHUTDOWN, DHT_JOINING, DHT_RUNNING, - DHT_SHUTDOWN, }; enum kad_code { @@ -277,7 +277,7 @@ static void dht_set_state(struct dht * dht, dht->state = state; - pthread_cond_signal(&dht->cond); + pthread_cond_broadcast(&dht->cond); pthread_mutex_unlock(&dht->mtx); } @@ -2245,7 +2245,10 @@ int dht_reg(struct dht * dht, assert(key); assert(dht->addr != 0); - if (dht_get_state(dht) != DHT_RUNNING) + if (dht_get_state(dht) < DHT_JOINING) + return -1; + + if (dht_wait_running(dht)) return -1; pthread_rwlock_wrlock(&dht->lock); @@ -2313,7 +2316,10 @@ uint64_t dht_query(struct dht * dht, addrs[0] = 0; - if (dht_get_state(dht) != DHT_RUNNING) + if (dht_get_state(dht) < DHT_JOINING) + return 0; + + if (dht_wait_running(dht)) return 0; pthread_rwlock_rdlock(&dht->lock); |