xiaoxiang781216 commented on code in PR #7525:
URL: https://github.com/apache/nuttx/pull/7525#discussion_r1038789173


##########
net/tcp/tcp_conn.c:
##########
@@ -836,10 +863,25 @@ void tcp_free(FAR struct tcp_conn_s *conn)
     }
 #endif
 
-  /* Mark the connection available and put it into the free list */
+  /* Mark the connection available. */
 
   conn->tcpstateflags = TCP_CLOSED;
-  dq_addlast(&conn->sconn.node, &g_free_tcp_connections);
+
+  /* Check if this is a preallocated connection to store it in the free
+   * connections list, else deallocate it.
+   */
+
+#ifdef CONFIG_NET_ALLOC_CONNS
+  if ((conn->flags & TCP_PREALLOC) == 0)
+    {
+      kmm_free(conn);

Review Comment:
   Let's summary my suggestion:
   
   1. NET_TCP_PREALLOC_CONNS to indicate the preallocated conn from .bss/data 
or heap:
   
      - zero disable the prealloation
   
   3. NET_TCP_ALLOC_CONNS to indicate the dynamic conn from heap:
   
      -  0 mean disable dynamical allocation at all
      - 1 mean allocate/free from heap every time
      - 2... mean allocate batch from heap, but not return to heap
   
   4. Remove NET_ALLOC_CONNS once all conn convert to this style since we can 
achieve the same functionality by setting NET_xxx_ALLOC_CONNS to zero or non 
zero.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to