Skip to content

Commit

Permalink
extmod/network_ninaw10: Fix select flags handling in socket poll.
Browse files Browse the repository at this point in the history
The flags returned from `select()` were misinterpreted to mean an error had
occurred for the socket, when it's actually just an exceptional condition
for the socket, such as OOB data.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
  • Loading branch information
iabdalkader authored and dpgeorge committed Oct 27, 2023
1 parent b6c369a commit 2fda94c
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions extmod/network_ninaw10.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,8 @@ STATIC void network_ninaw10_poll_sockets(mp_sched_node_t *node) {
// remove from poll list on error.
socket->callback = MP_OBJ_NULL;
mp_obj_list_remove(MP_STATE_PORT(mp_wifi_sockpoll_list), socket);
} else if (flags) {
} else if (flags & SOCKET_POLL_RD) {
mp_call_function_1(socket->callback, MP_OBJ_FROM_PTR(socket));
if (flags & SOCKET_POLL_ERR) {
// remove from poll list on error.
socket->callback = MP_OBJ_NULL;
mp_obj_list_remove(MP_STATE_PORT(mp_wifi_sockpoll_list), socket);
}
}
}
}
Expand Down Expand Up @@ -451,7 +446,7 @@ STATIC int network_ninaw10_socket_poll(mod_network_socket_obj_t *socket, uint32_
}
mp_uint_t start = mp_hal_ticks_ms();
for (; !(flags & rwf); mp_hal_delay_ms(5)) {
if (nina_socket_poll(socket->fileno, &flags) < 0 || (flags & SOCKET_POLL_ERR)) {
if (nina_socket_poll(socket->fileno, &flags) < 0) {
nina_socket_errno(_errno);
debug_printf("socket_poll(%d) -> errno %d flags %d\n", socket->fileno, *_errno, flags);
return -1;
Expand Down

0 comments on commit 2fda94c

Please sign in to comment.