From 3dda9647855b6e7ca265d77027d8eefc143a74b9 Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Wed, 3 Apr 2019 16:43:44 +1100
Subject: [PATCH] extmod/modlwip: Use correct listening socket object in accept
 callback.

Since commit da938a83b587c7387b8849f795f3497735d14267 the tcp_arg() that is
set for the new connection is the new connection itself, and the parent
listening socket is found in the pcb->connected entry.
---
 extmod/modlwip.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/extmod/modlwip.c b/extmod/modlwip.c
index af19648a6..7ebfa8904 100644
--- a/extmod/modlwip.c
+++ b/extmod/modlwip.c
@@ -447,7 +447,8 @@ STATIC err_t _lwip_tcp_recv_unaccepted(void *arg, struct tcp_pcb *pcb, struct pb
 // from accept callback itself.
 STATIC err_t _lwip_tcp_accept_finished(void *arg, struct tcp_pcb *pcb)
 {
-    lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg;
+    // The ->connected entry of the pcb holds the listening socket of the accept
+    lwip_socket_obj_t *socket = (lwip_socket_obj_t*)pcb->connected;
     tcp_poll(pcb, NULL, 0);
     exec_user_callback(socket);
     return ERR_OK;
-- 
GitLab