Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in_calyptia_fleet: add missing release function on collect #8124

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
in_calyptia_fleet: add missing release function on collect
Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
  • Loading branch information
nokute78 committed Nov 3, 2023
commit ede8507c2f1c72de4a3c144a6ccd166cf5f8d62e
23 changes: 17 additions & 6 deletions plugins/in_calyptia_fleet/in_calyptia_fleet.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,14 +760,14 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins,
flb_sds_t cfgnewname;
flb_sds_t cfgoldname;
flb_sds_t cfgcurname;
flb_sds_t header;
flb_sds_t header = NULL;
flb_sds_t hdr;
FILE *cfgfp;
const char *fbit_last_modified;
int fbit_last_modified_len;
struct flb_tm tm_last_modified = { 0 };
time_t time_last_modified;
char *data;
char *data = NULL;
size_t b_sent;
int ret = -1;
#ifdef FLB_SYSTEM_WINDOWS
Expand Down Expand Up @@ -842,7 +842,7 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins,

if (ret == -1) {
flb_plg_error(ctx->ins, "unable to get last-modified header");
goto http_error;
goto payload_error;
}

flb_strptime(fbit_last_modified, "%a, %d %B %Y %H:%M:%S GMT", &tm_last_modified);
Expand All @@ -855,7 +855,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);
goto http_error;
goto payload_error;
}

header = flb_sds_create_size(4096);
Expand Down Expand Up @@ -904,17 +904,18 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins,
}
if (hdr == NULL) {
fclose(cfgfp);
goto http_error;
goto header_error;
}
if (ctx->machine_id) {
hdr = flb_sds_printf(&header, " machine_id %s\n", ctx->machine_id);
if (hdr == NULL) {
fclose(cfgfp);
goto http_error;
goto header_error;
}
}
fwrite(header, strlen(header), 1, cfgfp);
flb_sds_destroy(header);
header = NULL;
fwrite(data, client->resp.payload_size, 1, cfgfp);
fclose(cfgfp);

Expand Down Expand Up @@ -943,6 +944,7 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins,
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);
Expand All @@ -960,6 +962,15 @@ static int in_calyptia_fleet_collect(struct flb_input_instance *ins,
ret = 0;

reload_error:
header_error:
if (header) {
flb_sds_destroy(header);
}
payload_error:
if (data) {
flb_sds_destroy(data);
}

http_error:
flb_http_client_destroy(client);
client_error:
Expand Down
Loading