summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2018-02-25 18:24:24 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2018-02-26 10:32:15 +0100
commitaa73255f3da1f7b2eecdf653f789dd8a0d1a156b (patch)
tree5afd6e09716cebd9f06e8c99c2f401d88e0506b1
parent728729592fc1864b46c6294cb5cf61f16ba04cd2 (diff)
downloadouroboros-aa73255f3da1f7b2eecdf653f789dd8a0d1a156b.tar.gz
ouroboros-aa73255f3da1f7b2eecdf653f789dd8a0d1a156b.zip
ipcpd: Fix data race when accessing DHT state
The dht_get_state() function should be used to get the state of the DHT. This fixes bug #4. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
-rw-r--r--src/ipcpd/normal/dht.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c
index 2577efc7..a3f6308c 100644
--- a/src/ipcpd/normal/dht.c
+++ b/src/ipcpd/normal/dht.c
@@ -2538,7 +2538,8 @@ static void * dht_handle_sdu(void * o)
if (msg->code != KAD_JOIN) {
pthread_rwlock_wrlock(&dht->lock);
- if (dht->state == DHT_JOINING && dht->buckets == NULL) {
+ if (dht_get_state(dht) == DHT_JOINING &&
+ dht->buckets == NULL) {
pthread_rwlock_unlock(&dht->lock);
break;
}