mirror of
https://github.com/netdata/netdata.git
synced 2025-04-17 11:12:42 +00:00
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.
This commit is contained in:
parent
479842e40f
commit
a54fcb7d75
4 changed files with 10 additions and 10 deletions
|
@ -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, "||");
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue