prevent double logging of streaming socket errors
Costa Tsaousis (ktsaou) committed
Oct 1, 2017 at 23:50 UTC
a47fd322cf5f5bd4a1255601c829af86621d79b5
2 files changed
+22
-15
src/clocks.c
+5
-1
@@ -115,8 +115,12 @@ usec_t heartbeat_next(heartbeat_t *hb, usec_t tick)
115
if(likely(*hb != 0ULL)) {
116
usec_t dt = now - *hb;
117
*hb = now;
118
- if(unlikely(dt >= tick + tick / 2))
118
+
119
+ if(unlikely(dt >= tick + tick / 2)) {
120
+ errno = 0;
121
error("heartbeat missed %llu microseconds", dt - tick);
122
+ }
123
+
124
return dt;
125
}
126
else {
src/rrdpush.c
+17
-14
@@ -588,20 +588,23 @@ void *rrdpush_sender_thread(void *ptr) {
588
}
589
}
590
591
- if(unlikely(ofd->revents & POLLERR)) {
592
- debug(D_STREAM, "STREAM: Send failed (POLLERR) - closing socket...");
593
- error("STREAM %s [send to %s]: connection reports errors (POLLERR), closing it - we have sent %zu bytes on this connection.", host->hostname, connected_to, sent_bytes_on_this_connection);
594
- rrdpush_sender_thread_close_socket(host);
595
- }
596
- else if(unlikely(ofd->revents & POLLHUP)) {
597
- debug(D_STREAM, "STREAM: Send failed (POLLHUP) - closing socket...");
598
- error("STREAM %s [send to %s]: connection closed by remote end (POLLHUP) - we have sent %zu bytes on this connection.", host->hostname, connected_to, sent_bytes_on_this_connection);
599
- rrdpush_sender_thread_close_socket(host);
600
- }
601
- else if(unlikely(ofd->revents & POLLNVAL)) {
602
- debug(D_STREAM, "STREAM: Send failed (POLLNVAL) - closing socket...");
603
- error("STREAM %s [send to %s]: connection is invalid (POLLNVAL), closing it - we have sent %zu bytes on this connection.", host->hostname, connected_to, sent_bytes_on_this_connection);
604
- rrdpush_sender_thread_close_socket(host);
591
+ if(host->rrdpush_sender_socket != -1) {
592
+ char *error = NULL;
593
+
594
+ if (unlikely(ofd->revents & POLLERR))
595
+ error = "socket reports errors (POLLERR)";
596
+
597
+ else if (unlikely(ofd->revents & POLLHUP))
598
+ error = "connection closed by remote end (POLLHUP)";
599
+
600
+ else if (unlikely(ofd->revents & POLLNVAL))
601
+ error = "connection is invalid (POLLNVAL)";
602
+
603
+ if(unlikely(error)) {
604
+ debug(D_STREAM, "STREAM: %s - closing socket...", error);
605
+ error("STREAM %s [send to %s]: %s - reopening socket - we have sent %zu bytes on this connection.", host->hostname, connected_to, error, sent_bytes_on_this_connection);
606
+ rrdpush_sender_thread_close_socket(host);
607
+ }
608
}
609
}
610
else {