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:
parent
86039057f8
commit
039a3eccf4
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue