diff options
-rw-r--r-- | claim/claim.c | 3 | ||||
-rw-r--r-- | database/sqlite/sqlite_functions.c | 8 | ||||
-rw-r--r-- | streaming/receiver.c | 3 |
3 files changed, 7 insertions, 7 deletions
diff --git a/claim/claim.c b/claim/claim.c index bce231a9bc..b29afe6df2 100644 --- a/claim/claim.c +++ b/claim/claim.c @@ -165,8 +165,7 @@ void load_claiming_state(void) } localhost->aclk_state.claimed_id = claimed_id; - if (likely(claimed_id)) - store_claim_id(&localhost->host_uuid, &uuid); + store_claim_id(&localhost->host_uuid, claimed_id ? &uuid : NULL); rrdhost_aclk_state_unlock(localhost); if (!claimed_id) { diff --git a/database/sqlite/sqlite_functions.c b/database/sqlite/sqlite_functions.c index 88d8d9ea55..a41ad44339 100644 --- a/database/sqlite/sqlite_functions.c +++ b/database/sqlite/sqlite_functions.c @@ -1341,8 +1341,7 @@ failed: #define SQL_STORE_CLAIM_ID "insert into node_instance " \ "(host_id, claim_id, date_created) values (@host_id, @claim_id, strftime('%s')) " \ - "on conflict(host_id) do update set node_id = null, claim_id = excluded.claim_id " \ - "where claim_id <> excluded.claim_id;" + "on conflict(host_id) do update set claim_id = excluded.claim_id;" void store_claim_id(uuid_t *host_id, uuid_t *claim_id) { @@ -1367,7 +1366,10 @@ void store_claim_id(uuid_t *host_id, uuid_t *claim_id) goto failed; } - rc = sqlite3_bind_blob(res, 2, claim_id, sizeof(*claim_id), SQLITE_STATIC); + if (claim_id) + rc = sqlite3_bind_blob(res, 2, claim_id, sizeof(*claim_id), SQLITE_STATIC); + else + rc = sqlite3_bind_null(res, 2); if (unlikely(rc != SQLITE_OK)) { error_report("Failed to bind claim_id parameter to store node instance information"); goto failed; diff --git a/streaming/receiver.c b/streaming/receiver.c index 8a3494ae1e..11191f3c78 100644 --- a/streaming/receiver.c +++ b/streaming/receiver.c @@ -131,8 +131,7 @@ PARSER_RC streaming_claimed_id(char **words, void *user, PLUGINSD_ACTION *plugin freez(host->aclk_state.claimed_id); host->aclk_state.claimed_id = strcmp(words[2], "NULL") ? strdupz(words[2]) : NULL; - if (likely(host->aclk_state.claimed_id)) - store_claim_id(&host->host_uuid, &uuid); + store_claim_id(&host->host_uuid, host->aclk_state.claimed_id ? &uuid : NULL); rrdhost_aclk_state_unlock(host); |