extmod/modlwip: accept: Fix error code for non-blocking mode.

In non-blocking mode, if no pending connection available, should return
EAGAIN, not ETIMEDOUT.
This commit is contained in:
Paul Sokolovsky 2017-06-04 13:45:37 +03:00
parent 5da8de2b66
commit 50de6d2fab
1 changed files with 3 additions and 1 deletions

View File

@ -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;