* Assumptions:
*
****************************************************************************/
-extern int lwip_close(int s);
+
int close(int fd)
{
int errcode;
int ret;
/* Did we get a valid file descriptor? */
-
+// printf("CONFIG_NFILE_DESCRIPTORS %d\n", CONFIG_NFILE_DESCRIPTORS);
+// printf("CONFIG_NSOCKET_DESCRIPTORS %d\n", CONFIG_NSOCKET_DESCRIPTORS);
+// printf("fd %d\n", fd);
if ((unsigned int)fd >= CONFIG_NFILE_DESCRIPTORS)
{
/* Close a socket descriptor */
-#ifndef SUPPORT_RECOVERY_DISPLAY
-// #if 1
- if (1)
+
+#if defined(CONFIG_NET_LWIP_SACK)
+
+#if defined(WEBSOCKET_CLOSE_FIX)
+ extern int lwip_close(int s);
+ if(1)
+ {
+ ret = lwip_close(fd);
+#else
+ if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS))
+ {
+ ret = closesocket(fd);
+#endif
+ if (ret < 0)
{
- ret = lwip_close(fd);
- if (ret < 0)
- {
- errcode = -ret;
- goto errout;
- }
-
- return ret;
+ errcode = -ret;
+ goto errout;
}
- else
+
+ return ret;
+ }
+ else
#endif
+ {
{
errcode = EBADF;
goto errout;
#define SIO_UART_FLOW_CTRL UART_FLOW_CTRL_NONE
#endif
+#define CONFIG_NET_LWIP_SACK 0 //Selective Acknowledgment(选择性确认) 重传指定的包
+#define WEBSOCKET_CLOSE_FIX 0 //解决关闭socket时,导致其他文件被错误关闭问题。 0:不修复 1:修复 暂时还不能使用,代码逻辑先预留。应该在新的1201以后的patch上的库估计才能有用。
#define LWIP_HTTPC_HAVE_FILE_IO 1
/*
#if defined (LOSCFG_CONFIG_MQTT)
#ifndef CONFIG_NFILE_DESCRIPTORS
-#define CONFIG_NFILE_DESCRIPTORS 128
+#define CONFIG_NFILE_DESCRIPTORS 1 //128
#endif
#endif
#endif
#ifndef DEFAULT_LWIP_NUM_SOCKETS
-#define DEFAULT_LWIP_NUM_SOCKETS 12
+#define DEFAULT_LWIP_NUM_SOCKETS 12 //最大支持12个socket 在socket创建时有效
#endif /* DEFAULT_LWIP_NUM_SOCKETS */
#ifndef MEMP_NUM_PBUF