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

out_cloudwatch_logs: alloc event buffer to max size in init #2333

Merged
merged 1 commit into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
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
15 changes: 0 additions & 15 deletions plugins/out_cloudwatch_logs/cloudwatch_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,6 @@ int add_event(struct flb_cloudwatch *ctx, struct cw_flush *buf,
{
int ret;
struct cw_event *event;
int new_len;
size_t size;
int retry_add = FLB_FALSE;
int event_bytes = 0;

Expand All @@ -531,19 +529,6 @@ int add_event(struct flb_cloudwatch *ctx, struct cw_flush *buf,
reset_flush_buf(ctx, buf, stream);
}

/* re-alloc event buffer if needed */
if ((buf->event_index + 1) >= buf->events_capacity) {
new_len = MAX_EVENTS_PER_PUT;
size = sizeof(struct cw_event) * new_len;
flb_plg_debug(ctx->ins, "Increasing event buffer to %d", new_len);
buf->events = flb_realloc(buf->events, size);
if (!buf->events) {
flb_errno();
return -1;
}
buf->events_capacity = new_len;
}

retry_add_event:
ret = process_event(ctx, buf, obj, tms);
if (ret < 0) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/out_cloudwatch_logs/cloudwatch_logs.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,13 @@ static int cb_cloudwatch_init(struct flb_output_instance *ins,
}
buf->tmp_buf_size = PUT_LOG_EVENTS_PAYLOAD_SIZE;

buf->events = flb_malloc(sizeof(struct cw_event) * 1000);
buf->events = flb_malloc(sizeof(struct cw_event) * MAX_EVENTS_PER_PUT);
if (!buf->events) {
flb_errno();
cw_flush_destroy(buf);
goto error;
}
buf->events_capacity = 1000;
buf->events_capacity = MAX_EVENTS_PER_PUT;

ctx->buf = buf;

Expand Down