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 #4290 and #5172.
pull/1/head
Damien George 2019-10-16 17:34:11 +11:00
parent feaa251674
commit 26d8fd2c0a
1 changed files with 3 additions and 2 deletions

View File

@ -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) {