mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 07:45:16 +08:00
Performance optimizations in connection allocations.
This commit is contained in:
committed by
Alin Jerpelea
parent
e9158efd42
commit
5e625b9cdb
@@ -205,13 +205,10 @@ void bluetooth_conn_free(FAR struct bluetooth_conn_s *conn)
|
|||||||
bluetooth_container_free(container);
|
bluetooth_container_free(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset structure */
|
|
||||||
|
|
||||||
memset(conn, 0, sizeof(*conn));
|
|
||||||
|
|
||||||
/* If this is a preallocated or a batch allocated connection store it in
|
/* If this is a preallocated or a batch allocated connection store it in
|
||||||
* the free connections list. Else free it.
|
* the free connections list. Else free it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_NET_BLUETOOTH_ALLOC_CONNS == 1
|
#if CONFIG_NET_BLUETOOTH_ALLOC_CONNS == 1
|
||||||
if (conn < g_bluetooth_connections || conn >= (g_bluetooth_connections +
|
if (conn < g_bluetooth_connections || conn >= (g_bluetooth_connections +
|
||||||
CONFIG_NET_BLUETOOTH_PREALLOC_CONNS))
|
CONFIG_NET_BLUETOOTH_PREALLOC_CONNS))
|
||||||
@@ -221,6 +218,7 @@ void bluetooth_conn_free(FAR struct bluetooth_conn_s *conn)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
memset(conn, 0, sizeof(*conn));
|
||||||
dq_addlast(&conn->bc_conn.node, &g_free_bluetooth_connections);
|
dq_addlast(&conn->bc_conn.node, &g_free_bluetooth_connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -182,10 +182,6 @@ void can_free(FAR struct can_conn_s *conn)
|
|||||||
|
|
||||||
dq_rem(&conn->sconn.node, &g_active_can_connections);
|
dq_rem(&conn->sconn.node, &g_active_can_connections);
|
||||||
|
|
||||||
/* Reset structure */
|
|
||||||
|
|
||||||
memset(conn, 0, sizeof(*conn));
|
|
||||||
|
|
||||||
/* If this is a preallocated or a batch allocated connection store it in
|
/* If this is a preallocated or a batch allocated connection store it in
|
||||||
* the free connections list. Else free it.
|
* the free connections list. Else free it.
|
||||||
*/
|
*/
|
||||||
@@ -199,6 +195,7 @@ void can_free(FAR struct can_conn_s *conn)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
memset(conn, 0, sizeof(*conn));
|
||||||
dq_addlast(&conn->sconn.node, &g_free_can_connections);
|
dq_addlast(&conn->sconn.node, &g_free_can_connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -182,10 +182,6 @@ void icmp_free(FAR struct icmp_conn_s *conn)
|
|||||||
|
|
||||||
dq_rem(&conn->sconn.node, &g_active_icmp_connections);
|
dq_rem(&conn->sconn.node, &g_active_icmp_connections);
|
||||||
|
|
||||||
/* Clear the connection structure */
|
|
||||||
|
|
||||||
memset(conn, 0, sizeof(*conn));
|
|
||||||
|
|
||||||
/* If this is a preallocated or a batch allocated connection store it
|
/* If this is a preallocated or a batch allocated connection store it
|
||||||
* in the free connections list. Else free it.
|
* in the free connections list. Else free it.
|
||||||
*/
|
*/
|
||||||
@@ -199,6 +195,7 @@ void icmp_free(FAR struct icmp_conn_s *conn)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
memset(conn, 0, sizeof(*conn));
|
||||||
dq_addlast(&conn->sconn.node, &g_free_icmp_connections);
|
dq_addlast(&conn->sconn.node, &g_free_icmp_connections);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,13 +172,10 @@ void icmpv6_free(FAR struct icmpv6_conn_s *conn)
|
|||||||
|
|
||||||
dq_rem(&conn->sconn.node, &g_active_icmpv6_connections);
|
dq_rem(&conn->sconn.node, &g_active_icmpv6_connections);
|
||||||
|
|
||||||
/* Clear the connection structure */
|
|
||||||
|
|
||||||
memset(conn, 0, sizeof(*conn));
|
|
||||||
|
|
||||||
/* If this is a preallocated or a batch allocated connection store it in
|
/* If this is a preallocated or a batch allocated connection store it in
|
||||||
* the free connections list. Else free it.
|
* the free connections list. Else free it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if CONFIG_NET_ICMPv6_ALLOC_CONNS == 1
|
#if CONFIG_NET_ICMPv6_ALLOC_CONNS == 1
|
||||||
if (conn < g_icmpv6_connections || conn >= (g_icmpv6_connections +
|
if (conn < g_icmpv6_connections || conn >= (g_icmpv6_connections +
|
||||||
CONFIG_NET_ICMPv6_PREALLOC_CONNS))
|
CONFIG_NET_ICMPv6_PREALLOC_CONNS))
|
||||||
@@ -188,6 +185,7 @@ void icmpv6_free(FAR struct icmpv6_conn_s *conn)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
memset(conn, 0, sizeof(*conn));
|
||||||
dq_addlast(&conn->sconn.node, &g_free_icmpv6_connections);
|
dq_addlast(&conn->sconn.node, &g_free_icmpv6_connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -194,10 +194,6 @@ void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn)
|
|||||||
ieee802154_container_free(container);
|
ieee802154_container_free(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enqueue the connection into the active list */
|
|
||||||
|
|
||||||
memset(conn, 0, sizeof(*conn));
|
|
||||||
|
|
||||||
/* If this is a preallocated or a batch allocated connection store it in
|
/* If this is a preallocated or a batch allocated connection store it in
|
||||||
* the free connections list. Else free it.
|
* the free connections list. Else free it.
|
||||||
*/
|
*/
|
||||||
@@ -211,6 +207,7 @@ void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
memset(conn, 0, sizeof(*conn));
|
||||||
dq_addlast(&conn->sconn.node, &g_free_ieee802154_connections);
|
dq_addlast(&conn->sconn.node, &g_free_ieee802154_connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -205,10 +205,6 @@ void netlink_free(FAR struct netlink_conn_s *conn)
|
|||||||
kmm_free(resp);
|
kmm_free(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset structure */
|
|
||||||
|
|
||||||
memset(conn, 0, sizeof(*conn));
|
|
||||||
|
|
||||||
/* If this is a preallocated or a batch allocated connection store it in
|
/* If this is a preallocated or a batch allocated connection store it in
|
||||||
* the free connections list. Else free it.
|
* the free connections list. Else free it.
|
||||||
*/
|
*/
|
||||||
@@ -222,6 +218,7 @@ void netlink_free(FAR struct netlink_conn_s *conn)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
memset(conn, 0, sizeof(*conn));
|
||||||
dq_addlast(&conn->sconn.node, &g_free_netlink_connections);
|
dq_addlast(&conn->sconn.node, &g_free_netlink_connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -169,10 +169,6 @@ void pkt_free(FAR struct pkt_conn_s *conn)
|
|||||||
|
|
||||||
dq_rem(&conn->sconn.node, &g_active_pkt_connections);
|
dq_rem(&conn->sconn.node, &g_active_pkt_connections);
|
||||||
|
|
||||||
/* Make sure that the connection is marked as uninitialized */
|
|
||||||
|
|
||||||
memset(conn, 0, sizeof(*conn));
|
|
||||||
|
|
||||||
/* If this is a preallocated or a batch allocated connection store it in
|
/* If this is a preallocated or a batch allocated connection store it in
|
||||||
* the free connections list. Else free it.
|
* the free connections list. Else free it.
|
||||||
*/
|
*/
|
||||||
@@ -186,6 +182,7 @@ void pkt_free(FAR struct pkt_conn_s *conn)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
memset(conn, 0, sizeof(*conn));
|
||||||
dq_addlast(&conn->sconn.node, &g_free_pkt_connections);
|
dq_addlast(&conn->sconn.node, &g_free_pkt_connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -712,10 +712,6 @@ void udp_free(FAR struct udp_conn_s *conn)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Clear the connection structure */
|
|
||||||
|
|
||||||
memset(conn, 0, sizeof(*conn));
|
|
||||||
|
|
||||||
/* Free the connection.
|
/* Free the connection.
|
||||||
* If this is a preallocated or a batch allocated connection store it in
|
* If this is a preallocated or a batch allocated connection store it in
|
||||||
* the free connections list. Else free it.
|
* the free connections list. Else free it.
|
||||||
@@ -730,6 +726,7 @@ void udp_free(FAR struct udp_conn_s *conn)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
memset(conn, 0, sizeof(*conn));
|
||||||
dq_addlast(&conn->sconn.node, &g_free_udp_connections);
|
dq_addlast(&conn->sconn.node, &g_free_udp_connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,6 @@ void usrsock_free(FAR struct usrsock_conn_s *conn)
|
|||||||
/* Reset structure */
|
/* Reset structure */
|
||||||
|
|
||||||
nxsem_destroy(&conn->resp.sem);
|
nxsem_destroy(&conn->resp.sem);
|
||||||
memset(conn, 0, sizeof(*conn));
|
|
||||||
|
|
||||||
/* If this is a preallocated or a batch allocated connection store it in
|
/* If this is a preallocated or a batch allocated connection store it in
|
||||||
* the free connections list. Else free it.
|
* the free connections list. Else free it.
|
||||||
@@ -166,6 +165,7 @@ void usrsock_free(FAR struct usrsock_conn_s *conn)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
memset(conn, 0, sizeof(*conn));
|
||||||
dq_addlast(&conn->sconn.node, &g_free_usrsock_connections);
|
dq_addlast(&conn->sconn.node, &g_free_usrsock_connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user