From bf4fb162500fd92937f81d028d7604b3fcaac750 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 23 Mar 2020 23:52:33 +1100 Subject: [PATCH] esp32/modsocket: Handle poll of a closed socket. This gets tests/extmod/uselect_poll_basic.py working on the esp32. --- ports/esp32/modsocket.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/esp32/modsocket.c b/ports/esp32/modsocket.c index 1252a18c51..dcb979b9c6 100644 --- a/ports/esp32/modsocket.c +++ b/ports/esp32/modsocket.c @@ -676,6 +676,9 @@ STATIC mp_uint_t socket_stream_write(mp_obj_t self_in, const void *buf, mp_uint_ STATIC mp_uint_t socket_stream_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) { socket_obj_t *socket = self_in; if (request == MP_STREAM_POLL) { + if (socket->fd == -1) { + return MP_STREAM_POLL_NVAL; + } fd_set rfds; FD_ZERO(&rfds);