From 50de6d2fab9ad67c6df0d74ce4b8c3704d1de090 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 4 Jun 2017 13:45:37 +0300 Subject: [PATCH] extmod/modlwip: accept: Fix error code for non-blocking mode. In non-blocking mode, if no pending connection available, should return EAGAIN, not ETIMEDOUT. --- extmod/modlwip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extmod/modlwip.c b/extmod/modlwip.c index d243985ad0..01190d200c 100644 --- a/extmod/modlwip.c +++ b/extmod/modlwip.c @@ -732,7 +732,9 @@ STATIC mp_obj_t lwip_socket_accept(mp_obj_t self_in) { // accept incoming connection if (socket->incoming.connection == NULL) { - if (socket->timeout != -1) { + if (socket->timeout == 0) { + mp_raise_OSError(MP_EAGAIN); + } else if (socket->timeout != -1) { for (mp_uint_t retries = socket->timeout / 100; retries--;) { mp_hal_delay_ms(100); if (socket->incoming.connection != NULL) break;