From 7499d04834da6c3774923972d927229b10189e62 Mon Sep 17 00:00:00 2001
From: yangchen <yangchen145@huawei.com>
Date: Mon, 22 Jan 2024 12:52:09 +0800
Subject: [PATCH] optimize recv exit process for FIN and unsupport SO_RCVBUF

---
 src/lstack/api/lstack_wrap.c  | 1 +
 src/lstack/core/lstack_lwip.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
index 3db62c7..372e102 100644
--- a/src/lstack/api/lstack_wrap.c
+++ b/src/lstack/api/lstack_wrap.c
@@ -372,6 +372,7 @@ static bool unsupport_optname(int32_t optname)
         optname == SO_SNDTIMEO  ||
         optname == SO_RCVTIMEO  ||
         optname == SO_SNDBUF    ||
+        optname == SO_RCVBUF    ||
         optname == TCP_INFO     ||
         optname == TCP_MAXSEG   ||
         optname == TCP_CONGESTION) {
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 6ebe589..ce218f5 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -1016,7 +1016,7 @@ ssize_t do_lwip_read_from_stack(int32_t fd, void *buf, size_t len, int32_t flags
             } else {
                 while (gazelle_ring_read(sock->recv_ring, (void **)&pbuf, 1) != 1 && recvd == 0) {
                     /* if the connection is disconnected, recv return 0 */
-                    if ((sock->errevent > 0 || (sock->conn->pcb.tcp->flags & TF_FIN)) && !NETCONN_IS_DATAIN(sock)) {
+                    if (sock->errevent > 0 && !NETCONN_IS_DATAIN(sock)) {
                         return 0;
                     }
 
-- 
2.33.0

