out_tcp: check connection first (#6208)
out_tcp: check connection first (#6208)

compose_payload allocates memory when 'format' is not 'msgpack'.
It is not released when no connection is available and it causes issue #6208.

This patch is to change flush flow.

1. Check connection
2. Invoke compose_payload

Signed-off-by: Takahiro Yamashita <8b9f03f78cb27351a99f79113f99e589b65190d5@gmail.com>

nokute78/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,nokute78/fluent-bit,fluent/fluent-bit,fluent/fluent-bit,nokute78/fluent-bit