Skip to content

Commit a817b79

Browse files
nokute78mgeriesa
authored andcommitted
out_tcp: check connection first (fluent#6208)
compose_payload allocates memory when 'format' is not 'msgpack'. It is not released when no connection is available and it causes issue fluent#6208. This patch is to change flush flow. 1. Check connection 2. Invoke compose_payload Signed-off-by: Takahiro Yamashita <[email protected]> Signed-off-by: Manal Geries <[email protected]>
1 parent 7b74c9e commit a817b79

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

plugins/out_tcp/tcp.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ static void cb_tcp_flush(struct flb_event_chunk *event_chunk,
9494
size_t out_size = 0;
9595
(void) i_ins;
9696

97-
ret = compose_payload(ctx, event_chunk->data, event_chunk->size,
98-
&out_payload, &out_size);
99-
if (ret != FLB_OK) {
100-
return FLB_OUTPUT_RETURN(ret);
101-
}
102-
10397
/* Get upstream context and connection */
10498
u = ctx->u;
10599
u_conn = flb_upstream_conn_get(u);
@@ -109,6 +103,13 @@ static void cb_tcp_flush(struct flb_event_chunk *event_chunk,
109103
FLB_OUTPUT_RETURN(FLB_RETRY);
110104
}
111105

106+
ret = compose_payload(ctx, event_chunk->data, event_chunk->size,
107+
&out_payload, &out_size);
108+
if (ret != FLB_OK) {
109+
flb_upstream_conn_release(u_conn);
110+
return FLB_OUTPUT_RETURN(ret);
111+
}
112+
112113
if (ctx->out_format == FLB_PACK_JSON_FORMAT_NONE) {
113114
ret = flb_io_net_write(u_conn,
114115
event_chunk->data, event_chunk->size,

0 commit comments

Comments
 (0)