Skip to content

Commit

Permalink
tcp_netpoll.c:modify the return value when dev is down
Browse files Browse the repository at this point in the history
when dev is down, tcp_pollsetup returns the value 'OK' and sets the connection status to 'down' and eventset to POLLERR & POLLUP

Signed-off-by: wangchen <[email protected]>
  • Loading branch information
wangchen61698 authored and xiaoxiang781216 committed Feb 25, 2025
1 parent dd441ac commit 07f721d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions net/tcp/tcp_netpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ int tcp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
}
}

if (conn->dev &&
!(netdev_verify(conn->dev) && IFF_IS_UP(conn->dev->d_flags)))
{
_SO_CONN_SETERRNO(conn, ENETDOWN);
eventset |= POLLERR | POLLHUP;
goto notify;
}

/* Allocate a TCP/IP callback structure */

cb = tcp_callback_alloc(conn);
Expand Down Expand Up @@ -356,6 +364,7 @@ int tcp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)

/* Check if any requested events are already in effect */

notify:
poll_notify(&fds, 1, eventset);

errout_with_lock:
Expand Down

0 comments on commit 07f721d

Please sign in to comment.