summaryrefslogtreecommitdiffstats
path: root/database/sqlite/sqlite_aclk.c
diff options
context:
space:
mode:
authorStelios Fragkakis <52996999+stelfrag@users.noreply.github.com>2022-07-07 00:19:02 +0300
committerGitHub <noreply@github.com>2022-07-07 00:19:02 +0300
commit072fadc74deaa7435482e090c308cf53bbee202b (patch)
treef44423771e30394abe34bb98bcba2ac40bb3c832 /database/sqlite/sqlite_aclk.c
parentbbb49318e4b432aa0b71b157fd1052052ec5d79f (diff)
Add hostname in the worker structure to avoid constant lookups (#13199)
Diffstat (limited to 'database/sqlite/sqlite_aclk.c')
-rw-r--r--database/sqlite/sqlite_aclk.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/database/sqlite/sqlite_aclk.c b/database/sqlite/sqlite_aclk.c
index c35a8d1944..32a1c05159 100644
--- a/database/sqlite/sqlite_aclk.c
+++ b/database/sqlite/sqlite_aclk.c
@@ -622,6 +622,8 @@ void aclk_database_worker(void *arg)
snprintfz(threadname, NETDATA_THREAD_NAME_MAX, "AS_%s", wc->host->hostname);
uv_thread_set_name_np(wc->thread, threadname);
wc->host->dbsync_worker = wc;
+ if (unlikely(!wc->hostname))
+ wc->hostname = strdupz(wc->host->hostname);
aclk_del_worker_thread(wc);
wc->node_info_send = 1;
}
@@ -674,6 +676,7 @@ void aclk_database_worker(void *arg)
rrd_rdlock();
if (likely(wc->host))
wc->host->dbsync_worker = NULL;
+ freez(wc->hostname);
freez(wc);
rrd_unlock();
@@ -743,13 +746,17 @@ void sql_create_aclk_table(RRDHOST *host, uuid_t *host_uuid, uuid_t *node_id)
return;
struct aclk_database_worker_config *wc = callocz(1, sizeof(struct aclk_database_worker_config));
- if (likely(host))
- host->dbsync_worker = (void *) wc;
+ if (node_id && !uuid_is_null(*node_id))
+ uuid_unparse_lower(*node_id, wc->node_id);
+ if (likely(host)) {
+ host->dbsync_worker = (void *)wc;
+ wc->hostname = strdupz(host->hostname);
+ }
+ else
+ wc->hostname = get_hostname_by_node_id(wc->node_id);
wc->host = host;
strcpy(wc->uuid_str, uuid_str);
strcpy(wc->host_guid, host_guid);
- if (node_id && !uuid_is_null(*node_id))
- uuid_unparse_lower(*node_id, wc->node_id);
wc->chart_updates = 0;
wc->alert_updates = 0;
wc->retry_count = 0;