ソースを参照

fix: lwip适配预防tcp_pcb重复free的问题 https://gitee.com/openLuat/LuatOS/commit/d0a2289f6ecfc36110995d02933827674d9a814e

Wendal Chen 2 年 前
コミット
7cc127575d
1 ファイル変更8 行追加1 行削除
  1. 8 1
      luatos/components/luat/port/luat_lwip_idf5.c

+ 8 - 1
luatos/components/luat/port/luat_lwip_idf5.c

@@ -357,10 +357,16 @@ static err_t net_lwip_tcp_err_cb(void *arg, err_t err)
 {
 	int socket_id = ((uint32_t)arg) & 0x0000ffff;
 	uint8_t adapter_index = ((uint32_t)arg) >> 16;
+	if (prvlwip.socket[socket_id].is_tcp)
+	{
+		if (prvlwip.socket[socket_id].pcb.tcp)
+		{
+			prvlwip.socket[socket_id].pcb.tcp = NULL;
+		}
+	}
 	if (!prvlwip.socket[socket_id].state && !prvlwip.socket[socket_id].remote_close)
 	{
 		NET_DBG("adapter %d socket %d not closing, but error %d", adapter_index, socket_id, err);
-		prvlwip.socket[socket_id].pcb.ip = NULL;
 		net_lwip_tcp_error(adapter_index, socket_id);
 	}
 	return 0;
@@ -584,6 +590,7 @@ static void net_lwip_close_tcp(int socket_id)
 	{
 		tcp_abort(prvlwip.socket[socket_id].pcb.tcp);
 	}
+	prvlwip.socket[socket_id].pcb.tcp = NULL;
 }
 
 static void net_lwip_task(void *param)