diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-09-08 10:03:17 +0000 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-09-08 10:03:17 +0000 |
commit | 7c69c0f6b25a199bb3632eea66ccb7de1db06ccc (patch) | |
tree | ab22bdbc69c0fd4d4c96c7177671a2b1135be2d5 /src | |
parent | 7693e3f335d0aab300410623aac7ae9dee2d3548 (diff) | |
parent | 08c1a279ed1909d7560038a3628598133f031742 (diff) | |
download | ouroboros-7c69c0f6b25a199bb3632eea66ccb7de1db06ccc.tar.gz ouroboros-7c69c0f6b25a199bb3632eea66ccb7de1db06ccc.zip |
Merged in dstaesse/ouroboros/be-dht-deadlock (pull request #588)
ipcpd: Shutdown DHT work thread first at destroy
Diffstat (limited to 'src')
-rw-r--r-- | src/ipcpd/normal/dht.c | 10 |
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); |