Skip to content

Commit

Permalink
in_calyptia_fleet: free up filenames and data during collect callback.
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Whelan <[email protected]>
  • Loading branch information
pwhelan committed Nov 3, 2023
1 parent 1563733 commit 611f94f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion plugins/in_calyptia_fleet/in_calyptia_fleet.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins,

if (cfgfp == NULL) {
flb_plg_error(ctx->ins, "unable to open configuration file: %s", cfgname);
flb_sds_destroy(cfgname);
goto http_error;
}

Expand Down Expand Up @@ -900,12 +901,14 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins,
}
if (hdr == NULL) {
fclose(cfgfp);
flb_sds_destroy(cfgname);
goto http_error;
}
if (ctx->machine_id) {
hdr = flb_sds_printf(&header, " machine_id %s\n", ctx->machine_id);
if (hdr == NULL) {
fclose(cfgfp);
flb_sds_destroy(cfgname);
goto http_error;
}
}
Expand Down Expand Up @@ -933,27 +936,34 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins,
flb_errno();
#endif
}

flb_sds_destroy(cfgnewname);
}

if (ctx->config_timestamp < time_last_modified) {
flb_plg_debug(ctx->ins, "new configuration is newer than current: %ld < %ld",
ctx->config_timestamp, time_last_modified);
flb_sds_destroy(data);

if (execute_reload(ctx, cfgname) == FLB_FALSE) {
cfgoldname = old_fleet_config_filename(ctx);
cfgcurname = cur_fleet_config_filename(ctx);
rename(cfgoldname, cfgcurname);
flb_sds_destroy(cfgcurname);
flb_sds_destroy(cfgoldname);
flb_sds_destroy(cfgname);
goto reload_error;
}
}
else {
flb_sds_destroy(cfgname);
}

ret = 0;

reload_error:
flb_sds_destroy(data);
http_error:
flb_plg_debug(ctx->ins, "freeing http client in fleet collect");
flb_http_client_destroy(client);
client_error:
flb_upstream_conn_release(u_conn);
Expand Down

0 comments on commit 611f94f

Please sign in to comment.