net/tcp: Set SO_ERROR for poll error in setup
Normally, `SO_ERROR` for disconn events will be set by `tcp_poll_eventhandler`, but when the socket is closed before poll, we should also set the `SO_ERROR`. On Linux, `tcp_poll` returns `EPOLLERR` event when `sk->sk_err` has value but doesn't let `poll` fail (doesn't set `errno`). https://github.com/torvalds/linux/blob/v6.5/net/ipv4/tcp.c#L594-L596 Note: `sk->sk_err` can be get by socket option `SO_ERROR` on Linux, so `POLLERR` will always be together with `SO_ERROR`. Common libs like curl may try to read `SO_ERROR` on `POLLERR`. Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
parent
e4721cef5c
commit
7c422381ca
@ -344,6 +344,7 @@ int tcp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
|
||||
* exceptional event.
|
||||
*/
|
||||
|
||||
_SO_CONN_SETERRNO(conn, ENOTCONN);
|
||||
eventset |= POLLERR | POLLHUP;
|
||||
}
|
||||
else if (_SS_ISCONNECTED(conn->sconn.s_flags) &&
|
||||
|
Loading…
Reference in New Issue
Block a user