diff --git a/plugins/custom_calyptia/calyptia.c b/plugins/custom_calyptia/calyptia.c index 1cfbbd5ce75..2ca8d3f68a8 100644 --- a/plugins/custom_calyptia/calyptia.c +++ b/plugins/custom_calyptia/calyptia.c @@ -37,6 +37,7 @@ struct calyptia { flb_sds_t cloud_host; flb_sds_t cloud_port; flb_sds_t machine_id; + int machine_id_auto_configured; /* used for reporting chunk trace records. */ #ifdef FLB_HAVE_CHUNK_TRACE @@ -426,6 +427,8 @@ static int cb_calyptia_init(struct flb_custom_instance *ins, flb_plg_error(ctx->ins, "unable to retrieve machine_id"); return -1; } + + ctx->machine_id_auto_configured = 1; } /* input collector */ @@ -517,6 +520,10 @@ static int cb_calyptia_exit(void *data, struct flb_config *config) return 0; } + if (ctx->machine_id && ctx->machine_id_auto_configured) { + flb_sds_destroy(ctx->machine_id); + } + flb_free(ctx); return 0; }