You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "pkarashchenko (via GitHub)" <gi...@apache.org> on 2023/02/21 21:57:21 UTC
[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #7525: Improvements in TCP connections allocation.
pkarashchenko commented on code in PR #7525:
URL: https://github.com/apache/nuttx/pull/7525#discussion_r1113605986
##########
net/ieee802154/ieee802154_conn.c:
##########
@@ -188,9 +198,22 @@ void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn)
memset(conn, 0, sizeof(*conn));
- /* Free the connection */
+ /* If this is a preallocated or a batch allocated connection store it in
+ * the free connections list. Else free it.
+ */
+
+#if CONFIG_NET_IEEE802154_ALLOC_CONNS == 1
+ if (conn < g_ieee802154_connections || conn >= (g_ieee802154_connections +
+ CONFIG_NET_IEEE802154_PREALLOC_CONNS))
+ {
+ kmm_free(conn);
+ }
+ else
+#endif
+ {
+ dq_addlast(&conn->sconn.node, &g_free_ieee802154_connections);
Review Comment:
Maybe we need to move `memset(conn, 0, sizeof(*conn));` here and do not spend extra cycles to `memset` memory that is going to be free-ed?
##########
net/netlink/netlink_conn.c:
##########
@@ -199,9 +209,22 @@ void netlink_free(FAR struct netlink_conn_s *conn)
memset(conn, 0, sizeof(*conn));
Review Comment:
ditto
##########
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:
Do we need `memset(conn, 0, sizeof(*conn));` before adding to the queue
##########
net/udp/udp_conn.c:
##########
@@ -703,9 +716,23 @@ void udp_free(FAR struct udp_conn_s *conn)
memset(conn, 0, sizeof(*conn));
Review Comment:
ditto
##########
net/usrsock/usrsock_conn.c:
##########
@@ -143,9 +153,22 @@ void usrsock_free(FAR struct usrsock_conn_s *conn)
nxsem_destroy(&conn->resp.sem);
memset(conn, 0, sizeof(*conn));
Review Comment:
ditto
##########
net/pkt/pkt_conn.c:
##########
@@ -164,9 +173,22 @@ void pkt_free(FAR struct pkt_conn_s *conn)
memset(conn, 0, sizeof(*conn));
Review Comment:
ditto
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org