From b15d12f7154e80674093597697ffc6af5a4230bf Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Tue, 1 May 2018 13:19:24 +0200 Subject: 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 Signed-off-by: Sander Vrijders --- src/ipcpd/normal/dht.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') 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."); -- cgit v1.2.3