diff --git a/src/flb_network.c b/src/flb_network.c index 13c8ecb27e8..627608764fd 100644 --- a/src/flb_network.c +++ b/src/flb_network.c @@ -543,7 +543,20 @@ static int net_connect_async(int fd, } /* Connection is broken, not much to do here */ +#if ((defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \ + (defined(_XOPEN_SOURCE) || _XOPEN_SOURCE - 0L >= 600L)) && \ + (!defined(_GNU_SOURCE)) + ret = strerror_r(error, so_error_buf, sizeof(so_error_buf)); + if (ret == 0) { + str = so_error_buf; + } + else { + flb_errno(); + return -1; + } +#else str = strerror_r(error, so_error_buf, sizeof(so_error_buf)); +#endif flb_error("[net] TCP connection failed: %s:%i (%s)", u->tcp_host, u->tcp_port, str); return -1;