diff options
-rw-r--r-- | daemon/analytics.c | 2 | ||||
-rw-r--r-- | database/rrd.h | 6 | ||||
-rw-r--r-- | streaming/rrdpush.c | 4 | ||||
-rw-r--r-- | streaming/sender.c | 8 |
4 files changed, 10 insertions, 10 deletions
diff --git a/daemon/analytics.c b/daemon/analytics.c index 69f6fe4c2d..6090169446 100644 --- a/daemon/analytics.c +++ b/daemon/analytics.c @@ -382,7 +382,7 @@ void analytics_https(void) BUFFER *b = buffer_create(30); #ifdef ENABLE_HTTPS analytics_exporting_connectors_ssl(b); - buffer_strcat(b, netdata_client_ctx && localhost->ssl.flags == NETDATA_SSL_HANDSHAKE_COMPLETE && localhost->rrdpush_sender_connected == 1 ? "streaming|" : "|"); + buffer_strcat(b, netdata_client_ctx && localhost->ssl.flags == NETDATA_SSL_HANDSHAKE_COMPLETE && __atomic_load_n(&localhost->rrdpush_sender_connected, __ATOMIC_SEQ_CST) ? "streaming|" : "|"); buffer_strcat(b, netdata_srv_ctx ? "web" : ""); #else buffer_strcat(b, "||"); diff --git a/database/rrd.h b/database/rrd.h index d5acbc4895..b07f34fa68 100644 --- a/database/rrd.h +++ b/database/rrd.h @@ -264,8 +264,8 @@ struct rrddim { RRD_MEMORY_MODE rrd_memory_mode; // the memory mode for this dimension RRDDIM_FLAGS flags; // configuration flags for the dimension - unsigned int updated:1; // 1 when the dimension has been updated since the last processing - unsigned int exposed:1; // 1 when set what have sent this dimension to the central netdata + bool updated; // 1 when the dimension has been updated since the last processing + bool exposed; // 1 when set what have sent this dimension to the central netdata collected_number multiplier; // the multiplier of the collected values collected_number divisor; // the divider of the collected values @@ -831,7 +831,7 @@ struct rrdhost { netdata_thread_t rrdpush_sender_thread; // the sender thread void *dbsync_worker; - volatile unsigned int rrdpush_sender_connected; // 1 when the sender is ready to push metrics + bool rrdpush_sender_connected; // 1 when the sender is ready to push metrics int rrdpush_sender_socket; // the fd of the socket to the remote host, or -1 volatile unsigned int rrdpush_sender_error_shown; // 1 when we have logged a communication error diff --git a/streaming/rrdpush.c b/streaming/rrdpush.c index a06a2f1245..9d2b62dbc7 100644 --- a/streaming/rrdpush.c +++ b/streaming/rrdpush.c @@ -334,7 +334,7 @@ void rrdset_done_push(RRDSET *st) { rrdpush_sender_thread_spawn(host); // Handle non-connected case - if(unlikely(!host->rrdpush_sender_connected)) { + if(unlikely(!__atomic_load_n(&host->rrdpush_sender_connected, __ATOMIC_SEQ_CST))) { if(unlikely(!host->rrdpush_sender_error_shown)) error("STREAM %s [send]: not ready - discarding collected metrics.", host->hostname); host->rrdpush_sender_error_shown = 1; @@ -383,7 +383,7 @@ void rrdpush_send_labels(RRDHOST *host) { void rrdpush_claimed_id(RRDHOST *host) { - if(unlikely(!host->rrdpush_send_enabled || !host->rrdpush_sender_connected)) + if(unlikely(!host->rrdpush_send_enabled || !__atomic_load_n(&host->rrdpush_sender_connected, __ATOMIC_SEQ_CST))) return; if(host->sender->version < STREAM_VERSION_CLAIM) 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; |