fix streaming bug; fixes #4370 (#4425)
Costa Tsaousis committed
Oct 17, 2018 at 22:34 UTC
5d23cb075af87f7a4e2d4fcab6b2e4225b1e6e35
1 file changed
+8
-1
streaming/rrdpush.c
+8
-1
@@ -539,6 +539,7 @@ void *rrdpush_sender_thread(void *ptr) {
539
size_t reconnects_counter = 0;
540
size_t sent_bytes = 0;
541
size_t sent_bytes_on_this_connection = 0;
542
+ size_t send_attempts = 0;
543
544
545
time_t last_sent_t = 0;
@@ -558,6 +559,8 @@ void *rrdpush_sender_thread(void *ptr) {
559
560
// if we don't have socket open, lets wait a bit
561
if(unlikely(host->rrdpush_sender_socket == -1)) {
562
+ send_attempts = 0;
563
+
564
if(not_connected_loops == 0 && sent_bytes_on_this_connection > 0) {
565
// fast re-connection on first disconnect
566
sleep_usec(USEC_PER_MS * 500); // milliseconds
@@ -573,6 +576,9 @@ void *rrdpush_sender_thread(void *ptr) {
576
// reset the buffer, to properly send charts and metrics
577
rrdpush_sender_thread_data_flush(host);
578
579
+ // send from the beginning
580
+ begin = 0;
581
+
582
// make sure the next reconnection will be immediate
583
not_connected_loops = 0;
584
@@ -594,7 +600,7 @@ void *rrdpush_sender_thread(void *ptr) {
600
continue;
601
}
602
else if(unlikely(now_monotonic_sec() - last_sent_t > timeout)) {
597
- error("STREAM %s [send to %s]: could not send metrics for %d seconds - closing connection - we have sent %zu bytes on this connection.", host->hostname, connected_to, timeout, sent_bytes_on_this_connection);
603
+ error("STREAM %s [send to %s]: could not send metrics for %d seconds - closing connection - we have sent %zu bytes on this connection via %zu send attempts.", host->hostname, connected_to, timeout, sent_bytes_on_this_connection, send_attempts);
604
rrdpush_sender_thread_close_socket(host);
605
}
606
@@ -608,6 +614,7 @@ void *rrdpush_sender_thread(void *ptr) {
614
debug(D_STREAM, "STREAM: Requesting data output on streaming socket %d...", ofd->fd);
615
ofd->events = POLLOUT;
616
fdmax = 2;
617
+ send_attempts++;
618
}
619
else {
620
debug(D_STREAM, "STREAM: Not requesting data output on streaming socket %d (nothing to send now)...", ofd->fd);