Skip to content

Commit 33474a6

Browse files
committed
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 <damien@micropython.org>
1 parent 894d7a5 commit 33474a6

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

extmod/modlwip.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,7 @@ static struct tcp_pcb *volatile *lwip_socket_incoming_array(lwip_socket_obj_t *s
371371
}
372372

373373
static void lwip_socket_free_incoming(lwip_socket_obj_t *socket) {
374-
bool socket_is_listener =
375-
socket->type == MOD_NETWORK_SOCK_STREAM
376-
&& socket->pcb.tcp->state == LISTEN;
377-
378-
if (!socket_is_listener) {
374+
if (socket->state != STATE_LISTENING) {
379375
if (socket->type == MOD_NETWORK_SOCK_STREAM) {
380376
if (socket->incoming.tcp.pbuf != NULL) {
381377
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_
16481644
tcp_err(socket->pcb.tcp, NULL);
16491645
tcp_recv(socket->pcb.tcp, NULL);
16501646

1651-
if (socket->pcb.tcp->state != LISTEN) {
1647+
if (socket->state != STATE_LISTENING) {
16521648
// Schedule a callback to abort the connection if it's not cleanly closed after
16531649
// the given timeout. The callback must be set before calling tcp_close since
16541650
// the latter may free the pcb; if it doesn't then the callback will be active.

0 commit comments

Comments
 (0)