net/inet: move recv/send timeout into socket_conn_s

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2022-02-07 14:36:54 +08:00 committed by Alan Carvalho de Assis
parent cc6add58dc
commit 3fce144aeb
19 changed files with 30 additions and 27 deletions

View File

@ -238,6 +238,8 @@ struct socket_conn_s
#ifdef CONFIG_NET_SOCKOPTS
int16_t s_error; /* Last error that occurred on this socket */
sockopt_t s_options; /* Selected socket options */
socktimeo_t s_rcvtimeo; /* Receive timeout value (in deciseconds) */
socktimeo_t s_sndtimeo; /* Send timeout value (in deciseconds) */
#endif
/* Connection-specific content may follow */
@ -258,8 +260,6 @@ struct socket
/* Socket options */
#ifdef CONFIG_NET_SOCKOPTS
socktimeo_t s_rcvtimeo; /* Receive timeout value (in deciseconds) */
socktimeo_t s_sndtimeo; /* Send timeout value (in deciseconds) */
#ifdef CONFIG_NET_SOLINGER
socktimeo_t s_linger; /* Linger timeout value (in deciseconds) */
#endif

View File

@ -450,7 +450,7 @@ ssize_t icmp_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
*/
ret = net_timedwait(&state.recv_sem,
_SO_TIMEOUT(psock->s_rcvtimeo));
_SO_TIMEOUT(conn->sconn.s_rcvtimeo));
if (ret < 0)
{
state.recv_result = ret;

View File

@ -418,7 +418,8 @@ ssize_t icmp_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
* net_timedwait will also terminate if a signal is received.
*/
ret = net_timedwait(&state.snd_sem, _SO_TIMEOUT(psock->s_sndtimeo));
ret = net_timedwait(&state.snd_sem,
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
if (ret < 0)
{
if (ret == -ETIMEDOUT)

View File

@ -459,7 +459,7 @@ ssize_t icmpv6_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
*/
ret = net_timedwait(&state.recv_sem,
_SO_TIMEOUT(psock->s_rcvtimeo));
_SO_TIMEOUT(conn->sconn.s_rcvtimeo));
if (ret < 0)
{
state.recv_result = ret;

View File

@ -409,7 +409,8 @@ ssize_t icmpv6_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
* net_timedwait will also terminate if a signal is received.
*/
ret = net_timedwait(&state.snd_sem, _SO_TIMEOUT(psock->s_sndtimeo));
ret = net_timedwait(&state.snd_sem,
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
if (ret < 0)
{
if (ret == -ETIMEDOUT)

View File

@ -693,7 +693,7 @@ static int rpmsg_socket_connect_internal(FAR struct socket *psock)
}
ret = net_timedwait(&conn->sendsem,
_SO_TIMEOUT(psock->s_rcvtimeo));
_SO_TIMEOUT(conn->sconn.s_rcvtimeo));
if (ret < 0)
{
@ -953,7 +953,7 @@ static ssize_t rpmsg_socket_send_continuous(FAR struct socket *psock,
if (!nonblock)
{
ret = net_timedwait(&conn->sendsem,
_SO_TIMEOUT(psock->s_sndtimeo));
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
if (!conn->ept.rdev)
{
ret = -ECONNRESET;
@ -1051,7 +1051,7 @@ static ssize_t rpmsg_socket_send_single(FAR struct socket *psock,
if (!nonblock)
{
ret = net_timedwait(&conn->sendsem,
_SO_TIMEOUT(psock->s_sndtimeo));
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
if (!conn->ept.rdev)
{
ret = -ECONNRESET;
@ -1233,7 +1233,7 @@ static ssize_t rpmsg_socket_recvmsg(FAR struct socket *psock,
rpmsg_socket_unlock(&conn->recvlock);
ret = net_timedwait(&conn->recvsem,
_SO_TIMEOUT(psock->s_rcvtimeo));
_SO_TIMEOUT(conn->sconn.s_rcvtimeo));
if (!conn->ept.rdev)
{
ret = -ECONNRESET;

View File

@ -799,7 +799,7 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
*/
ret = sixlowpan_send_packet(psock, dev, conn, buf, buflen, &destmac,
_SO_TIMEOUT(psock->s_sndtimeo));
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
if (ret < 0)
{
nerr("ERROR: sixlowpan_send_packet() failed: %d\n", ret);

View File

@ -297,7 +297,7 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
&conn->sconn.list_tail,
(FAR const struct ipv6_hdr_s *)&ipv6udp,
buf, buflen, &destmac,
_SO_TIMEOUT(psock->s_sndtimeo));
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
if (ret < 0)
{
nerr("ERROR: sixlowpan_send() failed: %d\n", ret);

View File

@ -115,11 +115,11 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
if (option == SO_RCVTIMEO)
{
timeo = psock->s_rcvtimeo;
timeo = conn->s_rcvtimeo;
}
else
{
timeo = psock->s_sndtimeo;
timeo = conn->s_sndtimeo;
}
/* Then return the timeout value to the caller */

View File

@ -78,8 +78,6 @@ int psock_dup2(FAR struct socket *psock1, FAR struct socket *psock2)
psock2->s_type = psock1->s_type; /* Protocol type: Only SOCK_STREAM or SOCK_DGRAM */
psock2->s_sockif = psock1->s_sockif; /* Socket interface */
#ifdef CONFIG_NET_SOCKOPTS
psock2->s_rcvtimeo = psock1->s_rcvtimeo; /* Receive timeout value (in deciseconds) */
psock2->s_sndtimeo = psock1->s_sndtimeo; /* Send timeout value (in deciseconds) */
#ifdef CONFIG_NET_SOLINGER
psock2->s_linger = psock1->s_linger; /* Linger timeout value (in deciseconds) */
#endif

View File

@ -116,11 +116,11 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
if (option == SO_RCVTIMEO)
{
psock->s_rcvtimeo = timeo;
conn->s_rcvtimeo = timeo;
}
else
{
psock->s_sndtimeo = timeo;
conn->s_sndtimeo = timeo;
}
/* Set/clear the corresponding enable/disable bit */

View File

@ -741,7 +741,8 @@ ssize_t psock_tcp_recvfrom(FAR struct socket *psock, FAR void *buf,
* received.
*/
ret = net_timedwait(&state.ir_sem, _SO_TIMEOUT(psock->s_rcvtimeo));
ret = net_timedwait(&state.ir_sem,
_SO_TIMEOUT(conn->sconn.s_rcvtimeo));
if (ret == -ETIMEDOUT)
{
ret = -EAGAIN;

View File

@ -666,7 +666,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock,
uint32_t acked = state.snd_acked;
ret = net_timedwait(&state.snd_sem,
_SO_TIMEOUT(psock->s_sndtimeo));
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
if (ret != -ETIMEDOUT || acked == state.snd_acked)
{
break; /* Timeout without any progress */

View File

@ -568,8 +568,8 @@ ssize_t tcp_sendfile(FAR struct socket *psock, FAR struct file *infile,
{
uint32_t acked = state.snd_acked;
ret = net_timedwait_uninterruptible(&state.snd_sem,
_SO_TIMEOUT(psock->s_sndtimeo));
ret = net_timedwait_uninterruptible(
&state.snd_sem, _SO_TIMEOUT(conn->sconn.s_sndtimeo));
if (ret != -ETIMEDOUT || acked == state.snd_acked)
{
break; /* Successful completion or timeout without any progress */

View File

@ -674,7 +674,8 @@ ssize_t psock_udp_recvfrom(FAR struct socket *psock, FAR void *buf,
* received.
*/
ret = net_timedwait(&state.ir_sem, _SO_TIMEOUT(psock->s_rcvtimeo));
ret = net_timedwait(&state.ir_sem,
_SO_TIMEOUT(conn->sconn.s_rcvtimeo));
if (ret == -ETIMEDOUT)
{
ret = -EAGAIN;

View File

@ -473,7 +473,8 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
* is received.
*/
ret = net_timedwait(&state.st_sem, _SO_TIMEOUT(psock->s_sndtimeo));
ret = net_timedwait(&state.st_sem,
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
if (ret >= 0)
{
/* The result of the sendto operation is the number of bytes

View File

@ -327,7 +327,7 @@ int usrsock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
/* Wait for receive-avail (or abort, or timeout, or signal). */
ret = net_timedwait(&state.reqstate.recvsem,
_SO_TIMEOUT(psock->s_rcvtimeo));
_SO_TIMEOUT(conn->sconn.s_rcvtimeo));
if (ret < 0)
{
if (ret == -ETIMEDOUT)

View File

@ -326,7 +326,7 @@ ssize_t usrsock_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
/* Wait for receive-avail (or abort, or timeout, or signal). */
ret = net_timedwait(&state.reqstate.recvsem,
_SO_TIMEOUT(psock->s_rcvtimeo));
_SO_TIMEOUT(conn->sconn.s_rcvtimeo));
if (ret < 0)
{
if (ret == -ETIMEDOUT)

View File

@ -307,7 +307,7 @@ ssize_t usrsock_sendmsg(FAR struct socket *psock,
/* Wait for send-ready (or abort, or timeout, or signal). */
ret = net_timedwait(&state.recvsem,
_SO_TIMEOUT(psock->s_sndtimeo));
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
if (ret < 0)
{
if (ret == -ETIMEDOUT)