summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/normal/dht.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c
index f24ed932..d139cb91 100644
--- a/src/ipcpd/normal/dht.c
+++ b/src/ipcpd/normal/dht.c
@@ -2335,8 +2335,11 @@ void dht_destroy(struct dht * dht)
if (dht == NULL)
return;
- if (dht_get_state(dht) == DHT_RUNNING)
+ if (dht_get_state(dht) == DHT_RUNNING) {
dht_set_state(dht, DHT_SHUTDOWN);
+ pthread_cancel(dht->worker);
+ pthread_join(dht->worker, NULL);
+ }
pthread_rwlock_wrlock(&dht->lock);
@@ -2366,11 +2369,6 @@ void dht_destroy(struct dht * dht)
pthread_rwlock_unlock(&dht->lock);
- if (dht_get_state(dht) == DHT_SHUTDOWN) {
- pthread_cancel(dht->worker);
- pthread_join(dht->worker, NULL);
- }
-
if (dht->buckets != NULL)
bucket_destroy(dht->buckets);