diff options
author | vkalintiris <vasilis@netdata.cloud> | 2022-07-07 11:09:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-07 11:09:56 +0300 |
commit | a54fcb7d75655801b27ebc310320e505cadac85a (patch) | |
tree | 1170caeeeb05d2c2e372f18ae6d2986d49e2a180 /streaming/sender.c | |
parent | 479842e40fc3ca17b848a7a279cdbddaec41b6dc (diff) |
Fix two helgrind reports (#13325)
* Use atomics ops with host->rrdpush_sender_connected.
* Use different storage unit for rrdim's updated and exposed fields.
The bitfields would end up in the same byte and thus requiring
explicit protection with mutexes.
Diffstat (limited to 'streaming/sender.c')
-rw-r--r-- | streaming/sender.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/streaming/sender.c b/streaming/sender.c index bf3444d902..e9e3559d34 100644 --- a/streaming/sender.c +++ b/streaming/sender.c @@ -80,7 +80,7 @@ void sender_commit(struct sender_state *s) { static inline void rrdpush_sender_thread_close_socket(RRDHOST *host) { - host->rrdpush_sender_connected = 0; + __atomic_clear(&host->rrdpush_sender_connected, __ATOMIC_SEQ_CST); if(host->rrdpush_sender_socket != -1) { close(host->rrdpush_sender_socket); @@ -102,7 +102,7 @@ static inline void rrdpush_sender_add_host_variable_to_buffer_nolock(RRDHOST *ho } void rrdpush_sender_send_this_host_variable_now(RRDHOST *host, RRDVAR *rv) { - if(host->rrdpush_send_enabled && host->rrdpush_sender_spawn && host->rrdpush_sender_connected) { + if(host->rrdpush_send_enabled && host->rrdpush_sender_spawn && __atomic_load_n(&host->rrdpush_sender_connected, __ATOMIC_SEQ_CST)) { sender_start(host->sender); rrdpush_sender_add_host_variable_to_buffer_nolock(host, rv); sender_commit(host->sender); @@ -563,7 +563,7 @@ static void attempt_to_connect(struct sender_state *state) state->sent_bytes_on_this_connection = 0; // let the data collection threads know we are ready - state->host->rrdpush_sender_connected = 1; + __atomic_test_and_set(&state->host->rrdpush_sender_connected, __ATOMIC_SEQ_CST); } else { // increase the failed connections counter @@ -770,7 +770,7 @@ void *rrdpush_sender_thread(void *ptr) { remote_clock_resync_iterations); // TODO: REMOVE FOR SLEW / GAPFILLING // initialize rrdpush globals - s->host->rrdpush_sender_connected = 0; + __atomic_clear(&s->host->rrdpush_sender_connected, __ATOMIC_SEQ_CST); if(pipe(s->host->rrdpush_sender_pipe) == -1) { error("STREAM %s [send]: cannot create required pipe. DISABLING STREAMING THREAD", s->host->hostname); return NULL; |