0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-17 03:02:41 +00:00

Replace write with read locks ()

This commit is contained in:
Emmanuel Vasilakis 2022-03-10 15:29:34 +02:00 committed by GitHub
parent d5baf4ca55
commit 026a875146
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 11 deletions

View file

@ -209,7 +209,7 @@ struct aclk_database_worker_config *find_inactive_wc_by_node_id(char *node_id)
void aclk_sync_exit_all()
{
rrd_wrlock();
rrd_rdlock();
RRDHOST *host = localhost;
while(host) {
struct aclk_database_worker_config *wc = host->dbsync_worker;
@ -572,7 +572,7 @@ void aclk_database_worker(void *arg)
freez(loop);
rrd_wrlock();
rrd_rdlock();
if (likely(wc->host))
wc->host->dbsync_worker = NULL;
freez(wc);
@ -820,7 +820,7 @@ void aclk_data_rotated(void)
return;
time_t next_rotation_time = now_realtime_sec()+ACLK_DATABASE_ROTATION_DELAY;
rrd_wrlock();
rrd_rdlock();
RRDHOST *this_host = localhost;
while (this_host) {
struct aclk_database_worker_config *wc = this_host->dbsync_worker;

View file

@ -297,7 +297,7 @@ void aclk_send_alarm_health_log(char *node_id)
memset(&cmd, 0, sizeof(cmd));
cmd.opcode = ACLK_DATABASE_ALARM_HEALTH_LOG;
rrd_wrlock();
rrd_rdlock();
RRDHOST *host = find_host_by_node_id(node_id);
if (likely(host))
wc = (struct aclk_database_worker_config *)host->dbsync_worker;
@ -325,7 +325,7 @@ void aclk_push_alarm_health_log(struct aclk_database_worker_config *wc, struct a
RRDHOST *host = wc->host;
if (unlikely(!host)) {
rrd_wrlock();
rrd_rdlock();
host = find_host_by_node_id(wc->node_id);
rrd_unlock();
@ -561,7 +561,7 @@ void aclk_start_alert_streaming(char *node_id, uint64_t batch_id, uint64_t start
return;
struct aclk_database_worker_config *wc = NULL;
rrd_wrlock();
rrd_rdlock();
RRDHOST *host = find_host_by_node_id(node_id);
if (likely(host))
wc = (struct aclk_database_worker_config *)host->dbsync_worker ?
@ -646,7 +646,7 @@ void aclk_process_send_alarm_snapshot(char *node_id, char *claim_id, uint64_t sn
return;
struct aclk_database_worker_config *wc = NULL;
rrd_wrlock();
rrd_rdlock();
RRDHOST *host = find_host_by_node_id(node_id);
if (likely(host))
wc = (struct aclk_database_worker_config *)host->dbsync_worker;

View file

@ -625,7 +625,7 @@ static void aclk_submit_param_command(char *node_id, enum aclk_database_opcode a
cmd.opcode = aclk_command;
cmd.param1 = param;
rrd_wrlock();
rrd_rdlock();
RRDHOST *host = find_host_by_node_id(node_id);
if (likely(host))
wc = (struct aclk_database_worker_config *)host->dbsync_worker;
@ -664,7 +664,7 @@ void aclk_start_streaming(char *node_id, uint64_t sequence_id, time_t created_at
return;
struct aclk_database_worker_config *wc = NULL;
rrd_wrlock();
rrd_rdlock();
RRDHOST *host = localhost;
while(host) {
if (host->node_id && !(uuid_compare(*host->node_id, node_uuid))) {

View file

@ -17,7 +17,7 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat
if (!wc->host)
return;
rrd_wrlock();
rrd_rdlock();
node_info.node_id = wc->node_id;
node_info.claim_id = is_agent_claimed();
node_info.machine_guid = wc->host_guid;

View file

@ -2031,7 +2031,7 @@ struct node_instance_list *get_node_list(void)
node_list = callocz(row + 1, sizeof(*node_list));
int max_rows = row;
row = 0;
rrd_wrlock();
rrd_rdlock();
while (sqlite3_step(res) == SQLITE_ROW) {
if (sqlite3_column_bytes(res, 0) == sizeof(uuid_t))
uuid_copy(node_list[row].node_id, *((uuid_t *)sqlite3_column_blob(res, 0)));