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 c5aebce commit 6d9d9be
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions 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 payload_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 header_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 header_error;
}
}
Expand Down Expand Up @@ -934,23 +937,27 @@ 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);
data = NULL;

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;

Expand All @@ -965,6 +972,7 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins,
}

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 6d9d9be

Please sign in to comment.