extmod/modlwip: Unconditionally return POLLHUP/POLLERR when polling.
POSIX poll should always return POLLERR and POLLHUP in revents, regardless
of whether they were requested in the input events flags.
See issues and
@@ -1476,13 +1476,14 @@ STATIC mp_uint_t lwip_socket_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_
ret |= flags & (MP_STREAM_POLL_RD | MP_STREAM_POLL_WR);
} else if (socket->state == ERR_RST) {
// Socket was reset by peer, a write will return an error
- ret |= flags & (MP_STREAM_POLL_WR | MP_STREAM_POLL_HUP);
+ ret |= flags & MP_STREAM_POLL_WR;
+ ret |= MP_STREAM_POLL_HUP;
} else if (socket->state == _ERR_BADF) {
ret |= MP_STREAM_POLL_NVAL;
} else if (socket->state < 0) {
// Socket in some other error state, use catch-all ERR flag
// TODO: may need to set other return flags here
- ret |= flags & MP_STREAM_POLL_ERR;
+ ret |= MP_STREAM_POLL_ERR;
}
} else if (request == MP_STREAM_CLOSE) {
