more function and variable renames
Costa Tsaousis (ktsaou) committed
Sep 23, 2017 at 15:49 UTC
336a85ea041e65030f02229eb925cd51f185e7e1
2 files changed
+20
-12
src/rrd.h
+15
-7
@@ -425,17 +425,25 @@ struct rrdhost {
425
// streaming of data to remote hosts - rrdpush
426
427
int rrdpush_send_enabled:1; // 1 when this host sends metrics to another netdata
428
- volatile int rrdpush_send_connected:1; // 1 when the sender is ready to push metrics
429
- volatile int rrdpush_sender_spawn:1; // 1 when the sender thread has been spawn
430
- volatile int rrdpush_sender_error_shown:1; // 1 when we have logged a communication error
431
- volatile int rrdpush_sender_join:1; // 1 when we have to join the sending thread
428
char *rrdpush_send_destination; // where to send metrics to
429
char *rrdpush_send_api_key; // the api key at the receiving netdata
434
- int rrdpush_sender_socket; // the fd of the socket to the remote host, or -1
430
+
431
+ // the following are state information for the threading
432
+ // streaming metrics from this netdata to an upstream netdata
433
+ volatile int rrdpush_sender_spawn:1; // 1 when the sender thread has been spawn
434
pthread_t rrdpush_sender_thread; // the sender thread
435
+
436
+ volatile int rrdpush_sender_connected:1; // 1 when the sender is ready to push metrics
437
+ int rrdpush_sender_socket; // the fd of the socket to the remote host, or -1
438
+
439
+ volatile int rrdpush_sender_error_shown:1; // 1 when we have logged a communication error
440
+ volatile int rrdpush_sender_join:1; // 1 when we have to join the sending thread
441
+
442
+ // metrics may be collected asynchronously
443
+ // these synchronize all the threads willing the write to our sending buffer
444
netdata_mutex_t rrdpush_sender_buffer_mutex; // exclusive access to rrdpush_sender_buffer
437
- int rrdpush_sender_pipe[2]; // collector to sender thread communication
438
- BUFFER *rrdpush_sender_buffer; // collector fills it, sender sends them
445
+ int rrdpush_sender_pipe[2]; // collector to sender thread signaling
446
+ BUFFER *rrdpush_sender_buffer; // collector fills it, sender sends it
447
448
449
// ------------------------------------------------------------------------
src/rrdpush.c
+5
-5
@@ -153,7 +153,7 @@ void rrdset_done_push(RRDSET *st) {
153
if(unlikely(host->rrdpush_send_enabled && !host->rrdpush_sender_spawn))
154
rrdpush_sender_thread_spawn(host);
155
156
- if(unlikely(!host->rrdpush_sender_buffer || !host->rrdpush_send_connected)) {
156
+ if(unlikely(!host->rrdpush_sender_buffer || !host->rrdpush_sender_connected)) {
157
if(unlikely(!host->rrdpush_sender_error_shown))
158
error("STREAM %s [send]: not ready - discarding collected metrics.", host->hostname);
159
@@ -261,7 +261,7 @@ static void rrdpush_sender_thread_cleanup_callback(void *ptr) {
261
rrdhost_wrlock(host);
262
263
info("STREAM %s [send]: sending thread cleans up...", host->hostname);
264
- host->rrdpush_send_connected = 0;
264
+ host->rrdpush_sender_connected = 0;
265
266
if(host->rrdpush_sender_socket != -1) {
267
close(host->rrdpush_sender_socket);
@@ -321,7 +321,7 @@ void *rrdpush_sender_thread(void *ptr) {
321
322
// initialize rrdpush globals
323
host->rrdpush_sender_buffer = buffer_create(1);
324
- host->rrdpush_send_connected = 0;
324
+ host->rrdpush_sender_connected = 0;
325
if(pipe(host->rrdpush_sender_pipe) == -1) fatal("STREAM %s [send]: cannot create required pipe.", host->hostname);
326
327
// initialize local variables
@@ -360,7 +360,7 @@ void *rrdpush_sender_thread(void *ptr) {
360
361
// stop appending data into rrdpush_sender_buffer
362
// they will be lost, so there is no point to do it
363
- host->rrdpush_send_connected = 0;
363
+ host->rrdpush_sender_connected = 0;
364
365
info("STREAM %s [send to %s]: connecting...", host->hostname, host->rrdpush_send_destination);
366
host->rrdpush_sender_socket = connect_to_one_of(host->rrdpush_send_destination, default_port, &tv, &reconnects_counter, connected_to, CONNECTED_TO_SIZE);
@@ -428,7 +428,7 @@ void *rrdpush_sender_thread(void *ptr) {
428
sent_connection = 0;
429
430
// allow appending data into rrdpush_sender_buffer
431
- host->rrdpush_send_connected = 1;
431
+ host->rrdpush_sender_connected = 1;
432
433
debug(D_STREAM, "STREAM: Connected on fd %d...", host->rrdpush_sender_socket);
434
}