Skip to content

Commit

Permalink
out_calyptia: initialize return and http context (CID 507836)
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <eduardo@calyptia.com>
  • Loading branch information
edsiper committed Aug 30, 2024
1 parent 3c367cd commit fe43ed1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions plugins/out_calyptia/calyptia.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ static int cb_calyptia_init(struct flb_output_instance *ins,

#ifdef FLB_HAVE_CHUNK_TRACE
ctx->trace_endpoint = flb_sds_create_size(256);
flb_sds_printf(&ctx->trace_endpoint, CALYPTIA_ENDPOINT_TRACE,
flb_sds_printf(&ctx->trace_endpoint, CALYPTIA_ENDPOINT_TRACE,
ctx->pipeline_id);
#endif /* FLB_HAVE_CHUNK_TRACE */
return 0;
Expand Down Expand Up @@ -790,7 +790,7 @@ static void cb_calyptia_flush(struct flb_event_chunk *event_chunk,
void *out_context,
struct flb_config *config)
{
int ret;
int ret = FLB_RETRY;
size_t off = 0;
size_t out_size = 0;
char *out_buf = NULL;
Expand All @@ -801,7 +801,7 @@ static void cb_calyptia_flush(struct flb_event_chunk *event_chunk,
#endif /* FLB_HAVE_CHUNK_TRACE */

struct flb_connection *u_conn;
struct flb_http_client *c;
struct flb_http_client *c = NULL;
struct flb_calyptia *ctx = out_context;
struct cmt *cmt;
(void) i_ins;
Expand Down Expand Up @@ -867,7 +867,7 @@ static void cb_calyptia_flush(struct flb_event_chunk *event_chunk,
cmt_encode_msgpack_destroy(out_buf);
}
}

#ifdef FLB_HAVE_CHUNK_TRACE
if (event_chunk->type == (FLB_EVENT_TYPE_LOGS | FLB_EVENT_TYPE_HAS_TRACE)) {
json = flb_pack_msgpack_to_json_format(event_chunk->data,
Expand Down Expand Up @@ -896,7 +896,7 @@ static void cb_calyptia_flush(struct flb_event_chunk *event_chunk,
flb_sds_destroy(ctx->metrics_endpoint);
FLB_OUTPUT_RETURN(FLB_RETRY);
}

/* perform request: 'ret' might be FLB_OK, FLB_ERROR or FLB_RETRY */
ret = calyptia_http_do(ctx, c, CALYPTIA_ACTION_TRACE);
if (ret == FLB_OK) {
Expand All @@ -911,7 +911,10 @@ static void cb_calyptia_flush(struct flb_event_chunk *event_chunk,
#endif /* FLB_HAVE_CHUNK_TRACE */

flb_upstream_conn_release(u_conn);
flb_http_client_destroy(c);

if (c) {
flb_http_client_destroy(c);
}
FLB_OUTPUT_RETURN(ret);
}

Expand Down

0 comments on commit fe43ed1

Please sign in to comment.