summaryrefslogtreecommitdiffstats
path: root/aclk
diff options
context:
space:
mode:
Diffstat (limited to 'aclk')
-rw-r--r--aclk/aclk.c2
-rw-r--r--aclk/aclk_rrdhost_state.h1
-rw-r--r--aclk/aclk_tx_msgs.c9
-rw-r--r--aclk/aclk_util.h1
4 files changed, 10 insertions, 3 deletions
diff --git a/aclk/aclk.c b/aclk/aclk.c
index fea83a1f8f..936f431b6b 100644
--- a/aclk/aclk.c
+++ b/aclk/aclk.c
@@ -320,7 +320,7 @@ static int handle_connection(mqtt_wss_client client)
return 1;
}
- if (disconnect_req) {
+ if (disconnect_req || aclk_kill_link) {
disconnect_req = 0;
aclk_graceful_disconnect(client);
aclk_queue_unlock();
diff --git a/aclk/aclk_rrdhost_state.h b/aclk/aclk_rrdhost_state.h
index 73925b3308..9138123dfe 100644
--- a/aclk/aclk_rrdhost_state.h
+++ b/aclk/aclk_rrdhost_state.h
@@ -30,6 +30,7 @@ typedef enum aclk_agent_state {
typedef struct aclk_rrdhost_state {
char *claimed_id; // Claimed ID if host has one otherwise NULL
+ char *prev_claimed_id; // Claimed ID if changed (reclaimed) during runtime
#ifdef ACLK_LEGACY
// per child popcorning
diff --git a/aclk/aclk_tx_msgs.c b/aclk/aclk_tx_msgs.c
index 5bfe28e5da..0f66ea4ea8 100644
--- a/aclk/aclk_tx_msgs.c
+++ b/aclk/aclk_tx_msgs.c
@@ -420,7 +420,10 @@ uint16_t aclk_send_agent_connection_update(mqtt_wss_client client, int reachable
rrdhost_aclk_state_unlock(localhost);
return 0;
}
- conn.claim_id = localhost->aclk_state.claimed_id;
+ if (localhost->aclk_state.prev_claimed_id)
+ conn.claim_id = localhost->aclk_state.prev_claimed_id;
+ else
+ conn.claim_id = localhost->aclk_state.claimed_id;
char *msg = generate_update_agent_connection(&len, &conn);
rrdhost_aclk_state_unlock(localhost);
@@ -432,6 +435,10 @@ uint16_t aclk_send_agent_connection_update(mqtt_wss_client client, int reachable
pid = aclk_send_bin_message_subtopic_pid(client, msg, len, ACLK_TOPICID_AGENT_CONN, "UpdateAgentConnection");
freez(msg);
+ if (localhost->aclk_state.prev_claimed_id) {
+ freez(localhost->aclk_state.prev_claimed_id);
+ localhost->aclk_state.prev_claimed_id = NULL;
+ }
return pid;
}
diff --git a/aclk/aclk_util.h b/aclk/aclk_util.h
index 07de5c58a3..4d8744e7f2 100644
--- a/aclk/aclk_util.h
+++ b/aclk/aclk_util.h
@@ -7,7 +7,6 @@
// Helper stuff which should not have any further inside ACLK dependency
// and are supposed not to be needed outside of ACLK
-
extern int aclk_use_new_cloud_arch;
extern usec_t aclk_session_newarch;