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


##########
net/tcp/tcp_conn.c:
##########
@@ -876,10 +889,26 @@ 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);
+
+  /* If this is a preallocated or a batch allocated connection store it in
+   * the free connections list. Else free it.
+   */
+
+#if CONFIG_NET_TCP_ALLOC_CONNS == 1
+  if (conn < g_tcp_connections || conn >= (g_tcp_connections +
+      CONFIG_NET_TCP_PREALLOC_CONNS))
+    {
+      kmm_free(conn);
+    }
+  else
+#endif
+    {
+      dq_addlast(&conn->sconn.node, &g_free_tcp_connections);

Review Comment:
   I think not. It seems that `tcp_free()` sets the contents of `conn` to 
specific values, for example see 
[this](https://github.com/apache/nuttx/blob/master/net/tcp/tcp_conn.c#L894).
   
   If someone knows for sure how this works, I can add a `memset()` and then 
set the flags, or whatever else is needed.



-- 
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