From aa73255f3da1f7b2eecdf653f789dd8a0d1a156b Mon Sep 17 00:00:00 2001
From: Dimitri Staessens <dimitri.staessens@ugent.be>
Date: Sun, 25 Feb 2018 18:24:24 +0100
Subject: 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>
---
 src/ipcpd/normal/dht.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'src')

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;
                         }
-- 
cgit v1.2.3