summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2018-05-01 13:19:24 +0200
committerSander Vrijders <[email protected]>2018-05-03 10:27:39 +0200
commitb15d12f7154e80674093597697ffc6af5a4230bf (patch)
tree5199a869b80210694b5c158fff93e02698502b08 /src/ipcpd/normal
parentf98a17855f20018b6a4635e26bae8c820eb192d2 (diff)
downloadouroboros-b15d12f7154e80674093597697ffc6af5a4230bf.tar.gz
ouroboros-b15d12f7154e80674093597697ffc6af5a4230bf.zip
ipcpd: Shut down DHT gracefully during enrollment
The DHT has a thread that continued to run during shutdown. The shutdown state is now checked for. It will not try to send messages at shutdown. Signed-off-by: Dimitri Staessens <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/ipcpd/normal')
-rw-r--r--src/ipcpd/normal/dht.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c
index a3f6308c..f90f95e4 100644
--- a/src/ipcpd/normal/dht.c
+++ b/src/ipcpd/normal/dht.c
@@ -2579,6 +2579,11 @@ static void dht_post_sdu(void * comp,
struct cmd * cmd;
struct dht * dht = (struct dht *) comp;
+ if (dht_get_state(dht) == DHT_SHUTDOWN) {
+ ipcp_sdb_release(sdb);
+ return;
+ }
+
cmd = malloc(sizeof(*cmd));
if (cmd == NULL) {
log_err("Command failed. Out of memory.");
@@ -2666,6 +2671,11 @@ static void * join_thr(void * o)
assert(info);
while (kad_join(info->dht, info->addr)) {
+ if (dht_get_state(info->dht) == DHT_SHUTDOWN) {
+ log_dbg("DHT enrollment aborted.");
+ goto finish;
+ }
+
if (retr++ == KAD_JOIN_RETR) {
dht_set_state(info->dht, DHT_INIT);
log_warn("DHT enrollment attempt failed.");