extmod/modlwip: Unconditionally return POLLHUP when polling new socket.

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.
This commit is contained in:
Damien George 2019-10-16 16:26:20 +11:00
parent 9ec73aedb4
commit 71401d5065
3 changed files with 3 additions and 4 deletions

View File

@ -1468,7 +1468,7 @@ STATIC mp_uint_t lwip_socket_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_
if (socket->state == STATE_NEW) {
// New sockets are not connected so set HUP
ret |= flags & MP_STREAM_POLL_HUP;
ret |= MP_STREAM_POLL_HUP;
} else if (socket->state == STATE_PEER_CLOSED) {
// Peer-closed socket is both readable and writable: read will
// return EOF, write - error. Without this poll will hang on a

View File

@ -12,9 +12,8 @@ def test(peer_addr):
poller.register(s)
# test poll before connect
# note: CPython can return POLLHUP, so use the IN|OUT mask
p = poller.poll(0)
print(len(p), p[0][-1] & (select.POLLIN | select.POLLOUT))
print(len(p), p[0][-1])
s.connect(peer_addr)

View File

@ -1,3 +1,3 @@
1 4
1 20
1
1 4