pkarashchenko commented on a change in pull request #5156:
URL: https://github.com/apache/incubator-nuttx/pull/5156#discussion_r778155218
##########
File path: net/usrsock/usrsock_conn.c
##########
@@ -94,23 +97,36 @@ static void _usrsock_semgive(FAR sem_t *sem)
FAR struct usrsock_conn_s *usrsock_alloc(void)
{
FAR struct usrsock_conn_s *conn;
+#ifdef CONFIG_NET_ALLOC_CONNS
+ int i;
+#endif
/* The free list is protected by a semaphore (that behaves like a mutex). */
_usrsock_semtake(&g_free_sem);
+#ifdef CONFIG_NET_ALLOC_CONNS
+ if (dq_peek(&g_free_usrsock_connections) == NULL)
+ {
+ conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_USRSOCK_CONNS);
+ if (conn != NULL)
+ {
+ for (i = 0; i < CONFIG_NET_USRSOCK_CONNS; i++)
+ {
+ dq_addlast(&conn[i].node, &g_free_usrsock_connections);
+ }
+ }
+ }
+#endif
Review comment:
In such case we do not limit the allocated connection number by
`CONFIG_NET_ALLOC_CONNS`. The current condition seems to be true for the first
time and when `CONFIG_NET_ALLOC_CONNS` number of connections are allocated.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]