diff options
| author | iabdalkader <i.abdalkader@gmail.com> | 2022-01-14 02:59:07 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-01-21 13:31:41 +1100 |
| commit | e401ff8935fb7764adede3ee4e0d9a6cf974c6c3 (patch) | |
| tree | 3905adb83f4314e07346866b31b5b4cc456a8c6e /extmod/network_ninaw10.c | |
| parent | 9a61bc3aa78058bf222dec3f01ce3b90fa79108a (diff) | |
drivers/ninaw10: Fix timeout handling to match modusocket.
Diffstat (limited to 'extmod/network_ninaw10.c')
| -rw-r--r-- | extmod/network_ninaw10.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/extmod/network_ninaw10.c b/extmod/network_ninaw10.c index c8fd0ce31..26b4a811d 100644 --- a/extmod/network_ninaw10.c +++ b/extmod/network_ninaw10.c @@ -406,7 +406,11 @@ STATIC int network_ninaw10_socket_accept(mod_network_socket_obj_t *socket, int fd = 0; // Call accept. int ret = nina_socket_accept(socket->fileno, ip, (uint16_t *)port, &fd, socket->timeout); - if (ret < 0) { + if (ret == NINA_ERROR_TIMEOUT) { + // The socket is Not closed on timeout when calling functions that accept a timeout. + *_errno = MP_ETIMEDOUT; + return -1; + } else if (ret < 0) { *_errno = ret; network_ninaw10_socket_close(socket); return -1; @@ -420,7 +424,11 @@ STATIC int network_ninaw10_socket_accept(mod_network_socket_obj_t *socket, STATIC int network_ninaw10_socket_connect(mod_network_socket_obj_t *socket, byte *ip, mp_uint_t port, int *_errno) { int ret = nina_socket_connect(socket->fileno, ip, port, socket->timeout); - if (ret < 0) { + if (ret == NINA_ERROR_TIMEOUT) { + // The socket is Not closed on timeout when calling functions that accept a timeout. + *_errno = MP_ETIMEDOUT; + return -1; + } else if (ret < 0) { *_errno = ret; network_ninaw10_socket_close(socket); return -1; @@ -536,10 +544,6 @@ STATIC int network_ninaw10_socket_setsockopt(mod_network_socket_obj_t *socket, m } STATIC int network_ninaw10_socket_settimeout(mod_network_socket_obj_t *socket, mp_uint_t timeout_ms, int *_errno) { - if (timeout_ms == UINT32_MAX) { - // no timeout is given, set the socket to blocking mode. - timeout_ms = 0; - } socket->timeout = timeout_ms; return 0; } |
