Skip to content

Commit fb0b394

Browse files
committed
output: safe cleanup on metricsprocessors failure
Signed-off-by: Eduardo Silva <[email protected]>
1 parent c79e421 commit fb0b394

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

include/fluent-bit/flb_output.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ struct flb_output_flush *flb_output_flush_create(struct flb_task *task,
813813
evc->size,
814814
&chunk_offset)) == CMT_DECODE_MSGPACK_SUCCESS) {
815815

816+
cmt_out_context = NULL;
816817
ret = flb_processor_run(o_ins->processor,
817818
0,
818819
FLB_PROCESSOR_METRICS,
@@ -831,7 +832,7 @@ struct flb_output_flush *flb_output_flush_create(struct flb_task *task,
831832
encode_context = metrics_context;
832833
}
833834

834-
/* if the cmetrics context lack of time series just skip it */
835+
/* if the cmetrics context lacks time series just skip it */
835836
if (flb_metrics_is_empty(encode_context)) {
836837
if (encode_context != metrics_context) {
837838
cmt_destroy(encode_context);
@@ -887,6 +888,16 @@ struct flb_output_flush *flb_output_flush_create(struct flb_task *task,
887888

888889
cmt_encode_msgpack_destroy(serialized_context_buffer);
889890
}
891+
else {
892+
cmt_destroy(metrics_context);
893+
if (cmt_out_context != NULL && cmt_out_context != metrics_context) {
894+
cmt_destroy(cmt_out_context);
895+
}
896+
flb_coro_destroy(coro);
897+
flb_free(out_flush);
898+
flb_free(p_buf);
899+
return NULL;
900+
}
890901
}
891902

892903
if (serialization_buffer_offset == 0) {
@@ -904,6 +915,7 @@ struct flb_output_flush *flb_output_flush_create(struct flb_task *task,
904915
0);
905916
}
906917
else {
918+
p_size = serialization_buffer_offset;
907919
out_flush->processed_event_chunk = flb_event_chunk_create(
908920
evc->type,
909921
0,

0 commit comments

Comments
 (0)