Skip to content

Commit 63ed88e

Browse files
cosmo0920edsiper
authored andcommitted
in_ebpf: Clean up ebpf promgrams on exception
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent fefcb6c commit 63ed88e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

plugins/in_ebpf/in_ebpf.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ static int in_ebpf_collect(struct flb_input_instance *ins, struct flb_config *co
142142
}
143143

144144
static int in_ebpf_init(struct flb_input_instance *ins, struct flb_config *config, void *data) {
145+
int i;
145146
struct flb_in_ebpf_context *ctx;
146147
struct mk_list *head;
147148
struct flb_kv *kv;
@@ -175,6 +176,14 @@ static int in_ebpf_init(struct flb_input_instance *ins, struct flb_config *confi
175176
flb_plg_debug(ctx->ins, "processing trace: %s", trace_name);
176177
if (trace_setup(ctx, trace_name) != 0) {
177178
flb_plg_error(ctx->ins, "failed to configure trace: %s", trace_name);
179+
for (i = 0; i < ctx->trace_count; i++) {
180+
ring_buffer__free(ctx->traces[i].rb);
181+
if (ctx->traces[i].skel_destroy) {
182+
ctx->traces[i].skel_destroy(ctx->traces[i].skel);
183+
}
184+
}
185+
flb_log_event_encoder_destroy(ctx->log_encoder);
186+
flb_free(ctx->traces);
178187
flb_free(ctx);
179188
return -1;
180189
}

0 commit comments

Comments
 (0)