Ensure psock_socket and psock_accept initialize s_crefs to 1
This simplifies the caller usage
This commit is contained in:
parent
9f9566c0eb
commit
0b860726db
@ -489,7 +489,6 @@ static int net_rpmsg_drv_sockioctl_task(int argc, FAR char *argv[])
|
|||||||
protocol = IPPROTO_ICMP6;
|
protocol = IPPROTO_ICMP6;
|
||||||
}
|
}
|
||||||
|
|
||||||
sock.s_crefs = 1; /* Initialize reference count manually */
|
|
||||||
msg->header.result = psock_socket(domain, type, protocol, &sock);
|
msg->header.result = psock_socket(domain, type, protocol, &sock);
|
||||||
if (msg->header.result >= 0)
|
if (msg->header.result >= 0)
|
||||||
{
|
{
|
||||||
|
@ -408,8 +408,7 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
|||||||
return errval;
|
return errval;
|
||||||
}
|
}
|
||||||
|
|
||||||
so->s_crefs = 1;
|
rpc->rc_so = so;
|
||||||
rpc->rc_so = so;
|
|
||||||
|
|
||||||
/* Always set receive timeout to detect server crash and reconnect.
|
/* Always set receive timeout to detect server crash and reconnect.
|
||||||
* Otherwise, we can get stuck in psock_receive forever.
|
* Otherwise, we can get stuck in psock_receive forever.
|
||||||
|
@ -1370,8 +1370,6 @@ static int userfs_bind(FAR struct inode *blkdriver, FAR const void *data,
|
|||||||
goto errout_with_alloc;
|
goto errout_with_alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->psock.s_crefs = 1;
|
|
||||||
|
|
||||||
/* Bind the socket to the client address */
|
/* Bind the socket to the client address */
|
||||||
|
|
||||||
client.sin_family = AF_INET;
|
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;
|
goto errout_with_psock;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->psock.s_crefs = 1;
|
|
||||||
|
|
||||||
/* Mounted! */
|
/* Mounted! */
|
||||||
|
|
||||||
*handle = (FAR void *)priv;
|
*handle = (FAR void *)priv;
|
||||||
|
@ -119,9 +119,7 @@ static void vnc_reset_session(FAR struct vnc_session_s *session,
|
|||||||
/* [Re-]initialize the session. */
|
/* [Re-]initialize the session. */
|
||||||
|
|
||||||
memset(&session->connect, 0, sizeof(struct socket));
|
memset(&session->connect, 0, sizeof(struct socket));
|
||||||
session->connect.s_crefs = 1;
|
|
||||||
memset(&session->listen, 0, sizeof(struct socket));
|
memset(&session->listen, 0, sizeof(struct socket));
|
||||||
session->listen.s_crefs = 1;
|
|
||||||
|
|
||||||
/* Put all of the pre-allocated update structures into the freelist */
|
/* Put all of the pre-allocated update structures into the freelist */
|
||||||
|
|
||||||
|
@ -879,6 +879,7 @@ static int inet_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
|||||||
|
|
||||||
/* Initialize the socket structure. */
|
/* Initialize the socket structure. */
|
||||||
|
|
||||||
|
newsock->s_crefs = 1;
|
||||||
newsock->s_domain = psock->s_domain;
|
newsock->s_domain = psock->s_domain;
|
||||||
newsock->s_type = SOCK_STREAM;
|
newsock->s_type = SOCK_STREAM;
|
||||||
newsock->s_sockif = psock->s_sockif;
|
newsock->s_sockif = psock->s_sockif;
|
||||||
|
@ -234,6 +234,7 @@ int local_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
|||||||
{
|
{
|
||||||
/* Setup the client socket structure */
|
/* Setup the client socket structure */
|
||||||
|
|
||||||
|
newsock->s_crefs = 1;
|
||||||
newsock->s_domain = psock->s_domain;
|
newsock->s_domain = psock->s_domain;
|
||||||
newsock->s_type = SOCK_STREAM;
|
newsock->s_type = SOCK_STREAM;
|
||||||
newsock->s_sockif = psock->s_sockif;
|
newsock->s_sockif = psock->s_sockif;
|
||||||
|
@ -60,11 +60,6 @@
|
|||||||
* socket() creates an endpoint for communication and returns a socket
|
* socket() creates an endpoint for communication and returns a socket
|
||||||
* structure.
|
* 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:
|
* Input Parameters:
|
||||||
* domain (see sys/socket.h)
|
* domain (see sys/socket.h)
|
||||||
* type (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 */
|
/* Initialize the socket structure */
|
||||||
|
|
||||||
|
psock->s_crefs = 1;
|
||||||
psock->s_domain = domain;
|
psock->s_domain = domain;
|
||||||
psock->s_type = type;
|
psock->s_type = type;
|
||||||
psock->s_conn = NULL;
|
psock->s_conn = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user