io: properly set the file descriptor mode according to the stream flags
int flb_io_net_accept(struct flb_connection *connection,
struct flb_coro *coro)
{
+ int flags;
int ret;
if (connection->fd != FLB_INVALID_SOCKET) {
@@ -84,6 +85,15 @@ int flb_io_net_accept(struct flb_connection *connection,
return -1;
}
+ /* Since flb_net_accept implicitly makes the client socket non blocking
+ * we have to restore it to blocking mode if FLB_IO_ASYNC is not specified
+ */
+ flags = flb_connection_get_flags(connection);
+
+ if (~flags & FLB_IO_ASYNC) {
+ flb_net_socket_blocking(connection->fd);
+ }
+
ret = flb_connection_get_remote_address(connection);
if (ret != 0) {
