From 883e987b90e82f0a9ab223910890da2c5d50b9d3 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 28 May 2019 17:43:00 +1000 Subject: [PATCH] esp32/modsocket: Raise EAGAIN when accept fails in non-blocking mode. EAGAIN should be for pure non-blocking mode and ETIMEDOUT for when there is a finite (but non-zero) timeout enabled. --- ports/esp32/modsocket.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ports/esp32/modsocket.c b/ports/esp32/modsocket.c index 1d7aec5efa..8b80e631db 100644 --- a/ports/esp32/modsocket.c +++ b/ports/esp32/modsocket.c @@ -253,7 +253,13 @@ STATIC mp_obj_t socket_accept(const mp_obj_t arg0) { if (errno != EAGAIN) exception_from_errno(errno); check_for_exceptions(); } - if (new_fd < 0) mp_raise_OSError(MP_ETIMEDOUT); + if (new_fd < 0) { + if (self->retries == 0) { + mp_raise_OSError(MP_EAGAIN); + } else { + mp_raise_OSError(MP_ETIMEDOUT); + } + } // create new socket object socket_obj_t *sock = m_new_obj_with_finaliser(socket_obj_t);