diff --git a/drivers/net/rpmsgdrv.c b/drivers/net/rpmsgdrv.c index ba451d1dc1..56e86b4ef2 100644 --- a/drivers/net/rpmsgdrv.c +++ b/drivers/net/rpmsgdrv.c @@ -489,7 +489,6 @@ static int net_rpmsg_drv_sockioctl_task(int argc, FAR char *argv[]) protocol = IPPROTO_ICMP6; } - sock.s_crefs = 1; /* Initialize reference count manually */ msg->header.result = psock_socket(domain, type, protocol, &sock); if (msg->header.result >= 0) { diff --git a/fs/nfs/rpc_clnt.c b/fs/nfs/rpc_clnt.c index a8d7c593e9..180c234098 100644 --- a/fs/nfs/rpc_clnt.c +++ b/fs/nfs/rpc_clnt.c @@ -408,8 +408,7 @@ int rpcclnt_connect(struct rpcclnt *rpc) return errval; } - so->s_crefs = 1; - rpc->rc_so = so; + rpc->rc_so = so; /* Always set receive timeout to detect server crash and reconnect. * Otherwise, we can get stuck in psock_receive forever. diff --git a/fs/userfs/fs_userfs.c b/fs/userfs/fs_userfs.c index 2bcadf6cdd..2d45a8f55b 100644 --- a/fs/userfs/fs_userfs.c +++ b/fs/userfs/fs_userfs.c @@ -1370,8 +1370,6 @@ static int userfs_bind(FAR struct inode *blkdriver, FAR const void *data, goto errout_with_alloc; } - priv->psock.s_crefs = 1; - /* Bind the socket to the client address */ client.sin_family = AF_INET; @@ -1386,8 +1384,6 @@ static int userfs_bind(FAR struct inode *blkdriver, FAR const void *data, goto errout_with_psock; } - priv->psock.s_crefs = 1; - /* Mounted! */ *handle = (FAR void *)priv; diff --git a/graphics/vnc/server/vnc_server.c b/graphics/vnc/server/vnc_server.c index c143a9a393..aaf6c98bff 100644 --- a/graphics/vnc/server/vnc_server.c +++ b/graphics/vnc/server/vnc_server.c @@ -119,9 +119,7 @@ static void vnc_reset_session(FAR struct vnc_session_s *session, /* [Re-]initialize the session. */ memset(&session->connect, 0, sizeof(struct socket)); - session->connect.s_crefs = 1; memset(&session->listen, 0, sizeof(struct socket)); - session->listen.s_crefs = 1; /* Put all of the pre-allocated update structures into the freelist */ diff --git a/net/inet/inet_sockif.c b/net/inet/inet_sockif.c index 8a66b89919..c42fdbba38 100644 --- a/net/inet/inet_sockif.c +++ b/net/inet/inet_sockif.c @@ -879,6 +879,7 @@ static int inet_accept(FAR struct socket *psock, FAR struct sockaddr *addr, /* Initialize the socket structure. */ + newsock->s_crefs = 1; newsock->s_domain = psock->s_domain; newsock->s_type = SOCK_STREAM; newsock->s_sockif = psock->s_sockif; diff --git a/net/local/local_accept.c b/net/local/local_accept.c index 24d509a4e0..e847f1c5f9 100644 --- a/net/local/local_accept.c +++ b/net/local/local_accept.c @@ -234,6 +234,7 @@ int local_accept(FAR struct socket *psock, FAR struct sockaddr *addr, { /* Setup the client socket structure */ + newsock->s_crefs = 1; newsock->s_domain = psock->s_domain; newsock->s_type = SOCK_STREAM; newsock->s_sockif = psock->s_sockif; diff --git a/net/socket/socket.c b/net/socket/socket.c index bf11bbe31a..635ec4dc94 100644 --- a/net/socket/socket.c +++ b/net/socket/socket.c @@ -60,11 +60,6 @@ * socket() creates an endpoint for communication and returns a socket * structure. * - * NOTE: This function does not set the reference count on the socket - * structure. This down by the socket() front end when socket structure - * was allocated. Internal OS users of psock_socket() must set the s_crefs - * field to one if psock_socket() returns success. - * * Input Parameters: * domain (see sys/socket.h) * type (see sys/socket.h) @@ -102,6 +97,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) /* Initialize the socket structure */ + psock->s_crefs = 1; psock->s_domain = domain; psock->s_type = type; psock->s_conn = NULL;