From 33474a6fdb3ce9853dd105e69c9c5a1484909a99 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 20 Aug 2025 18:24:57 +1000 Subject: [PATCH] extmod/modlwip: Adjust logic for determining a listening socket. This should be equivalent logic, and is a bit simpler and clearer now. Signed-off-by: Damien George --- extmod/modlwip.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/extmod/modlwip.c b/extmod/modlwip.c index 2a43256f3c..2d9cda8f17 100644 --- a/extmod/modlwip.c +++ b/extmod/modlwip.c @@ -371,11 +371,7 @@ static struct tcp_pcb *volatile *lwip_socket_incoming_array(lwip_socket_obj_t *s } static void lwip_socket_free_incoming(lwip_socket_obj_t *socket) { - bool socket_is_listener = - socket->type == MOD_NETWORK_SOCK_STREAM - && socket->pcb.tcp->state == LISTEN; - - if (!socket_is_listener) { + if (socket->state != STATE_LISTENING) { if (socket->type == MOD_NETWORK_SOCK_STREAM) { if (socket->incoming.tcp.pbuf != NULL) { pbuf_free(socket->incoming.tcp.pbuf); @@ -1648,7 +1644,7 @@ static mp_uint_t lwip_socket_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_ tcp_err(socket->pcb.tcp, NULL); tcp_recv(socket->pcb.tcp, NULL); - if (socket->pcb.tcp->state != LISTEN) { + if (socket->state != STATE_LISTENING) { // Schedule a callback to abort the connection if it's not cleanly closed after // the given timeout. The callback must be set before calling tcp_close since // the latter may free the pcb; if it doesn't then the callback will be active.