You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/10/19 01:46:07 UTC

[incubator-nuttx] branch master updated: net/tcp: remove debug counter of connect instance

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 6978446b8e net/tcp: remove debug counter of connect instance
6978446b8e is described below

commit 6978446b8ef7979ccfe7535d06e769252699d5a1
Author: chao an <an...@xiaomi.com>
AuthorDate: Tue Oct 18 22:52:58 2022 +0800

    net/tcp: remove debug counter of connect instance
    
    Fixed by commit:
    
     | net: remove pvconn reference from all devif callback
     |
     | Do not use 'pvconn' argument to get the connection pointer since
     | pvconn is normally NULL for some events like NETDEV_DOWN.
     | Instead, the connection pointer can be reliably obtained from the
     | corresponding private pointer.
    
    Signed-off-by: chao an <an...@xiaomi.com>
---
 net/tcp/tcp.h               |  4 ----
 net/tcp/tcp_send_buffered.c | 28 +++++++---------------------
 2 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h
index a76634630c..e3bf0bba66 100644
--- a/net/tcp/tcp.h
+++ b/net/tcp/tcp.h
@@ -310,10 +310,6 @@ struct tcp_conn_s
   /* Callback instance for TCP send() */
 
   FAR struct devif_callback_s *sndcb;
-
-#ifdef CONFIG_DEBUG_ASSERTIONS
-  int sndcb_alloc_cnt;    /* The callback allocation counter */
-#endif
 #endif
 
   /* accept() is called when the TCP logic has created a connection
diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c
index de96e60474..0789fd7b18 100644
--- a/net/tcp/tcp_send_buffered.c
+++ b/net/tcp/tcp_send_buffered.c
@@ -1182,30 +1182,16 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
         {
           conn->sndcb = tcp_callback_alloc(conn);
 
-#ifdef CONFIG_DEBUG_ASSERTIONS
-          if (conn->sndcb != NULL)
-            {
-              conn->sndcb_alloc_cnt++;
+          /* Test if the callback has been allocated */
 
-              /* The callback is allowed to be allocated only once.
-               * This is to catch a potential re-allocation after
-               * conn->sndcb was set to NULL.
-               */
+          if (conn->sndcb == NULL)
+            {
+              /* A buffer allocation error occurred */
 
-              DEBUGASSERT(conn->sndcb_alloc_cnt == 1);
+              nerr("ERROR: Failed to allocate callback\n");
+              ret = nonblock ? -EAGAIN : -ENOMEM;
+              goto errout_with_lock;
             }
-#endif
-        }
-
-      /* Test if the callback has been allocated */
-
-      if (conn->sndcb == NULL)
-        {
-          /* A buffer allocation error occurred */
-
-          nerr("ERROR: Failed to allocate callback\n");
-          ret = nonblock ? -EAGAIN : -ENOMEM;
-          goto errout_with_lock;
         }
 
       /* Set up the callback in the connection */