mirror of
https://github.com/netdata/netdata.git
synced 2025-04-17 03:02:41 +00:00
Replace write with read locks (#12309)
This commit is contained in:
parent
d5baf4ca55
commit
026a875146
5 changed files with 11 additions and 11 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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))) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)));
|
||||
|
|
Loading…
Add table
Reference in a new issue