Fix a segmentation fault in backends (#6627)
Vladimir Kobal committed
Aug 12, 2019 at 10:02 UTC
4e4f95411be93a83b18fc10b768263a3cd749508
1 file changed
+7
-8
backends/backends.c
+7
-8
@@ -658,7 +658,8 @@ void *backends_main(void *ptr) {
658
size_t count_dims_total = 0;
659
660
#if ENABLE_PROMETHEUS_REMOTE_WRITE
661
- clear_write_request();
661
+ if(do_prometheus_remote_write)
662
+ clear_write_request();
663
#endif
664
rrd_rdlock();
665
RRDHOST *host;
@@ -1027,14 +1028,14 @@ void *backends_main(void *ptr) {
1028
1029
1030
#if ENABLE_PROMETHEUS_REMOTE_WRITE
1030
- if(failures) {
1031
+ if(do_prometheus_remote_write && failures) {
1032
(void) buffer_on_failures;
1033
failures = 0;
1034
chart_lost_bytes = chart_buffered_bytes = get_write_request_size(); // estimated write request size
1035
chart_data_lost_events++;
1036
chart_lost_metrics = chart_buffered_metrics;
1036
- }
1037
-#else
1037
+ } else
1038
+#endif
1039
if(failures > buffer_on_failures) {
1040
// too bad! we are going to lose data
1041
chart_lost_bytes += buffer_strlen(b);
@@ -1044,7 +1045,6 @@ void *backends_main(void *ptr) {
1045
chart_data_lost_events++;
1046
chart_lost_metrics = chart_buffered_metrics;
1047
}
1047
-#endif /* ENABLE_PROMETHEUS_REMOTE_WRITE */
1048
1049
if(unlikely(netdata_exit)) break;
1050
@@ -1101,10 +1101,9 @@ cleanup:
1101
#endif
1102
1103
#if ENABLE_PROMETHEUS_REMOTE_WRITE
1104
- if(do_prometheus_remote_write) {
1105
- buffer_free(http_request_header);
1104
+ buffer_free(http_request_header);
1105
+ if(do_prometheus_remote_write)
1106
protocol_buffers_shutdown();
1107
- }
1107
#endif
1108
1109
if(sock != -1)