net/local: Initialize lc_crefs to 1

and remove local_addref call after local_alloc

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2024-02-28 10:47:17 +08:00 committed by Alan Carvalho de Assis
parent 86039057f8
commit 039a3eccf4
2 changed files with 2 additions and 11 deletions

View File

@ -118,9 +118,10 @@ FAR struct local_conn_s *local_alloc(void)
* necessary to zerio-ize any structure elements.
*/
conn->lc_crefs = 1;
#ifdef CONFIG_NET_LOCAL_STREAM
nxsem_init(&conn->lc_waitsem, 0, 0);
#endif
/* This semaphore is used for sending safely in multithread.
@ -174,10 +175,6 @@ int local_alloc_accept(FAR struct local_conn_s *server,
return -ENOMEM;
}
/* Initialize the new connection structure */
local_addref(conn);
conn->lc_proto = SOCK_STREAM;
conn->lc_type = LOCAL_TYPE_PATHNAME;
conn->lc_state = LOCAL_STATE_CONNECTED;

View File

@ -139,12 +139,6 @@ static int local_sockif_alloc(FAR struct socket *psock)
return -ENOMEM;
}
/* Set the reference count on the connection structure. This reference
* count will be incremented only if the socket is dup'ed
*/
local_addref(conn);
/* Save the pre-allocated connection in the socket structure */
psock->s_conn = conn;