This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 6ca2984a400 net/tcp: Do not panic when a socket has no free poll waiter
6ca2984a400 is described below
commit 6ca2984a40027d2444e15ba786fe316a399a2e14
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Nov 3 19:53:13 2026 +0100
net/tcp: Do not panic when a socket has no free poll waiter
tcp_pollsetup() calls DEBUGPANIC() when all CONFIG_NET_TCP_NPOLLWAITERS
containers of a socket are in use. With assertions on, a user program can
stop the system: a third poll() or epoll set on one socket is a kernel
panic. The UDP, ICMP, ICMPv6, packet and usrsock sockets return ENOMEM in
this case.
Return ENOMEM with a warning, as they do, and describe the limit in the
help of NET_TCP_NPOLLWAITERS.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
net/tcp/Kconfig | 5 +++++
net/tcp/tcp_netpoll.c | 3 ++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/tcp/Kconfig b/net/tcp/Kconfig
index 4475ca3d3e3..7d1f06d94d1 100644
--- a/net/tcp/Kconfig
+++ b/net/tcp/Kconfig
@@ -122,6 +122,11 @@ config NET_TCP_MAX_CONNS
config NET_TCP_NPOLLWAITERS
int "Number of TCP poll waiters"
default 2
+ ---help---
+ The number of poll() calls and epoll sets that can wait on one
+ TCP socket at the same time. One more fails with ENOMEM. A
+ server with several worker processes that all wait on the same
+ listening socket needs one per worker.
config NET_TCP_RTO
int "RTO of TCP/IP connections"
diff --git a/net/tcp/tcp_netpoll.c b/net/tcp/tcp_netpoll.c
index cf24dd66e95..ebed6bdfc36 100644
--- a/net/tcp/tcp_netpoll.c
+++ b/net/tcp/tcp_netpoll.c
@@ -231,7 +231,8 @@ int tcp_pollsetup(FAR struct socket *psock, FAR struct
pollfd_s *fds)
{
if (++info >= &conn->pollinfo[CONFIG_NET_TCP_NPOLLWAITERS])
{
- DEBUGPANIC();
+ nwarn("WARNING: more than %d poll waiters\n",
+ CONFIG_NET_TCP_NPOLLWAITERS);
ret = -ENOMEM;
goto errout_with_lock;
}