lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] The value of errno is incorrect when connect is repeatedly


From: wuchangsheng (C)
Subject: [lwip-devel] The value of errno is incorrect when connect is repeatedly invoked in non-blocking mode
Date: Wed, 24 Aug 2022 07:52:28 +0000

connet is non-blocking.

 

Call connect first and return -1 and errno=EINPROGRESS, which is as expected.

 

The three-way handshake is complete, and pcb->state=ESTABLITED. In the lwip_netconn_do_connected function, conn->state = NETCONN_NONE.

 

When the connect function is invoked for the second time, err = ERR_ISCONN is set only when msg->conn->state != NETCONN_NONE is determined in the lwip_netconn_do_connect function. However, in the lwip_netconn_do_connected function, conn->state has been set to NETCONN_NONE. As a result, the error ERR_ISCONN cannot be returned.

 

 

Therefore, I modify it as follows:

 

---

src/api/api_msg.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

 

diff --git a/src/api/api_msg.c b/src/api/api_msg.c

index 3f08e03..9081119 100644

--- a/src/api/api_msg.c

+++ b/src/api/api_msg.c

@@ -1375,7 +1375,7 @@ lwip_netconn_do_connect(void *m)

         /* Prevent connect while doing any other action. */

         if (msg->conn->state == NETCONN_CONNECT) {

           err = ERR_ALREADY;

-        } else if (msg->conn->state != NETCONN_NONE) {

+        } else if (msg->conn->pcb.tcp->state == ESTABLISHED) {

           err = ERR_ISCONN;

         } else {

           setup_tcp(msg->conn);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]