You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/06/07 17:15:49 UTC

[incubator-nuttx] 03/03: net/tcp: Search conn list again to aovid the race condition in tcp_timer_expiry

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 9d4c708913e6b414e6620911c364fc22c4061ebb
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Jun 5 23:43:17 2022 +0800

    net/tcp: Search conn list again to aovid the race condition in tcp_timer_expiry
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 net/tcp/tcp_timer.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/net/tcp/tcp_timer.c b/net/tcp/tcp_timer.c
index 800023dfaa..b17a26a189 100644
--- a/net/tcp/tcp_timer.c
+++ b/net/tcp/tcp_timer.c
@@ -138,11 +138,20 @@ static int tcp_get_timeout(FAR struct tcp_conn_s *conn)
 
 static void tcp_timer_expiry(FAR void *arg)
 {
-  FAR struct tcp_conn_s *conn = arg;
+  FAR struct tcp_conn_s *conn = NULL;
 
   net_lock();
-  conn->timeout = true;
-  netdev_txnotify_dev(conn->dev);
+
+  while ((conn = tcp_nextconn(conn)) != NULL)
+    {
+      if (conn == arg)
+        {
+          conn->timeout = true;
+          netdev_txnotify_dev(conn->dev);
+          break;
+        }
+    }
+
   net_unlock();
 }