tcp: decouple TCP_NODELAY and NET_TCP_KEEPALIVE

TCP_NODELAY is an independent configuration and does not depend on TCP_KEEPALIVE

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2024-04-29 15:10:08 +08:00 committed by Xiang Xiao
parent 0cd893fb5a
commit 45568229ef
2 changed files with 34 additions and 34 deletions

View File

@ -133,23 +133,6 @@ int tcp_getsockopt(FAR struct socket *psock, int option,
}
break;
case TCP_NODELAY: /* Avoid coalescing of small segments. */
if (*value_len < sizeof(int))
{
ret = -EINVAL;
}
else
{
FAR int *nodelay = (FAR int *)value;
/* Always true here since we do not support Nagle. */
*nodelay = 1;
*value_len = sizeof(int);
ret = OK;
}
break;
case TCP_KEEPIDLE: /* Start keepalives after this IDLE period */
case TCP_KEEPINTVL: /* Interval between keepalives */
{
@ -218,6 +201,23 @@ int tcp_getsockopt(FAR struct socket *psock, int option,
break;
#endif /* CONFIG_NET_TCP_KEEPALIVE */
case TCP_NODELAY: /* Avoid coalescing of small segments. */
if (*value_len < sizeof(int))
{
ret = -EINVAL;
}
else
{
FAR int *nodelay = (FAR int *)value;
/* Always true here since we do not support Nagle. */
*nodelay = 1;
*value_len = sizeof(int);
ret = OK;
}
break;
case TCP_MAXSEG: /* The maximum segment size */
if (*value_len < sizeof(int))
{

View File

@ -130,23 +130,6 @@ int tcp_setsockopt(FAR struct socket *psock, int option,
}
break;
case TCP_NODELAY: /* Avoid coalescing of small segments. */
if (value_len != sizeof(int))
{
ret = -EDOM;
}
else
{
int nodelay = *(FAR int *)value;
if (!nodelay)
{
nerr("ERROR: TCP_NODELAY not supported\n");
ret = -ENOSYS;
}
}
break;
case TCP_KEEPIDLE: /* Start keepalives after this IDLE period */
case TCP_KEEPINTVL: /* Interval between keepalives */
{
@ -230,6 +213,23 @@ int tcp_setsockopt(FAR struct socket *psock, int option,
break;
#endif /* CONFIG_NET_TCP_KEEPALIVE */
case TCP_NODELAY: /* Avoid coalescing of small segments. */
if (value_len != sizeof(int))
{
ret = -EDOM;
}
else
{
int nodelay = *(FAR int *)value;
if (!nodelay)
{
nerr("ERROR: TCP_NODELAY not supported\n");
ret = -ENOSYS;
}
}
break;
case TCP_MAXSEG: /* The maximum segment size */
if (value_len != sizeof(int))
{