From 9f998c64f5f48a103d7e290d1565ffc8588c7ff1 Mon Sep 17 00:00:00 2001 From: Dong Heng Date: Fri, 6 Jul 2018 16:10:28 +0800 Subject: [PATCH] feat(lwip): Fix UDP recv NULL package --- .../lwip/include/lwip/apps/multi-threads/sys/socket.h | 1 + components/lwip/lwip/src/api/api_lib.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/components/lwip/include/lwip/apps/multi-threads/sys/socket.h b/components/lwip/include/lwip/apps/multi-threads/sys/socket.h index 454457d3..0eef6f6d 100644 --- a/components/lwip/include/lwip/apps/multi-threads/sys/socket.h +++ b/components/lwip/include/lwip/apps/multi-threads/sys/socket.h @@ -106,6 +106,7 @@ int lwip_fcntl_mt(int s, int cmd, int val); #define read(a,b,c) lwip_read_mt(a,b,c) #define write(a,b,c) lwip_write_mt(a,b,c) #define close(s) lwip_close_mt(s) +#define closesocket(s) lwip_close_mt(s) #define fcntl(a,b,c) lwip_fcntl_mt(a,b,c) #endif /* LWIP_POSIX_SOCKETS_IO_NAMES */ diff --git a/components/lwip/lwip/src/api/api_lib.c b/components/lwip/lwip/src/api/api_lib.c index 3c1d6a6c..c428f32c 100644 --- a/components/lwip/lwip/src/api/api_lib.c +++ b/components/lwip/lwip/src/api/api_lib.c @@ -571,7 +571,14 @@ netconn_recv_data(struct netconn *conn, void **new_buf) #endif /* LWIP_TCP && (LWIP_UDP || LWIP_RAW) */ #if (LWIP_UDP || LWIP_RAW) { +#ifdef SOCKETS_MT + if (!buf) { + API_EVENT(conn, NETCONN_EVT_ERROR, 0); + return ERR_CLSD; + } +#else LWIP_ASSERT("buf != NULL", buf != NULL); +#endif len = netbuf_len((struct netbuf*)buf); } #endif /* (LWIP_UDP || LWIP_RAW) */