From 039a3eccf407ea6d6b1efdc3fd5fa57bea088b5c Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Wed, 28 Feb 2024 10:47:17 +0800 Subject: [PATCH] net/local: Initialize lc_crefs to 1 and remove local_addref call after local_alloc Signed-off-by: Xiang Xiao --- net/local/local_conn.c | 7 ++----- net/local/local_sockif.c | 6 ------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/net/local/local_conn.c b/net/local/local_conn.c index d8797c53fa..834bd23ce0 100644 --- a/net/local/local_conn.c +++ b/net/local/local_conn.c @@ -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; diff --git a/net/local/local_sockif.c b/net/local/local_sockif.c index 0b57ba0049..847aa2e258 100644 --- a/net/local/local_sockif.c +++ b/net/local/local_sockif.c @@ -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;