From 0100e8338e5b35478ce4a808238f4bef949e3a76 Mon Sep 17 00:00:00 2001 From: liqinhui Date: Fri, 24 Mar 2023 16:30:27 +0800 Subject: [PATCH] net: Fix unreadable error when doing poll operation on tcp socket. When do poll operation and the tcp connection state is TCP_ALLOCATED, eventset(POLLERR|POLLHUP) is return, causing the libuv poll_multiple_handles to fail. Verification: Use the libuv test case ` uv_run_tests poll_multiple_handles`. Signed-off-by: liqinhui --- net/tcp/tcp_netpoll.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/tcp/tcp_netpoll.c b/net/tcp/tcp_netpoll.c index 2f1ca92b565..796c0a8b0eb 100644 --- a/net/tcp/tcp_netpoll.c +++ b/net/tcp/tcp_netpoll.c @@ -219,7 +219,8 @@ int tcp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) /* Non-blocking connection ? */ - nonblock_conn = (conn->tcpstateflags == TCP_SYN_SENT && + nonblock_conn = ((conn->tcpstateflags == TCP_ALLOCATED || + conn->tcpstateflags == TCP_SYN_SENT) && _SS_ISNONBLOCK(conn->sconn.s_flags)); /* Find a container to hold the poll information */