mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 05:16:47 +08:00
TCP_CORK and TCP_NODELAY behave almost exactly the opposite, so first provide simple support for TCP_CORK. Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
@@ -57,5 +57,6 @@
|
|||||||
#define TCP_KEEPCNT (__SO_PROTOCOL + 3) /* Number of keepalives before death
|
#define TCP_KEEPCNT (__SO_PROTOCOL + 3) /* Number of keepalives before death
|
||||||
* Argument: max retry count */
|
* Argument: max retry count */
|
||||||
#define TCP_MAXSEG (__SO_PROTOCOL + 4) /* The maximum segment size */
|
#define TCP_MAXSEG (__SO_PROTOCOL + 4) /* The maximum segment size */
|
||||||
|
#define TCP_CORK (__SO_PROTOCOL + 5) /* Coalescing of small segments */
|
||||||
|
|
||||||
#endif /* __INCLUDE_NETINET_TCP_H */
|
#endif /* __INCLUDE_NETINET_TCP_H */
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ int tcp_getsockopt(FAR struct socket *psock, int option,
|
|||||||
#endif /* CONFIG_NET_TCP_KEEPALIVE */
|
#endif /* CONFIG_NET_TCP_KEEPALIVE */
|
||||||
|
|
||||||
case TCP_NODELAY: /* Avoid coalescing of small segments. */
|
case TCP_NODELAY: /* Avoid coalescing of small segments. */
|
||||||
|
case TCP_CORK: /* coalescing of small segments. */
|
||||||
if (*value_len < sizeof(int))
|
if (*value_len < sizeof(int))
|
||||||
{
|
{
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
@@ -214,7 +215,7 @@ int tcp_getsockopt(FAR struct socket *psock, int option,
|
|||||||
|
|
||||||
/* Always true here since we do not support Nagle. */
|
/* Always true here since we do not support Nagle. */
|
||||||
|
|
||||||
*nodelay = 1;
|
*nodelay = option == TCP_NODELAY ? 1 : 0;
|
||||||
*value_len = sizeof(int);
|
*value_len = sizeof(int);
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,6 +216,7 @@ int tcp_setsockopt(FAR struct socket *psock, int option,
|
|||||||
#endif /* CONFIG_NET_TCP_KEEPALIVE */
|
#endif /* CONFIG_NET_TCP_KEEPALIVE */
|
||||||
|
|
||||||
case TCP_NODELAY: /* Avoid coalescing of small segments. */
|
case TCP_NODELAY: /* Avoid coalescing of small segments. */
|
||||||
|
case TCP_CORK: /* coalescing of small segments. */
|
||||||
if (value_len != sizeof(int))
|
if (value_len != sizeof(int))
|
||||||
{
|
{
|
||||||
ret = -EDOM;
|
ret = -EDOM;
|
||||||
@@ -224,9 +225,11 @@ int tcp_setsockopt(FAR struct socket *psock, int option,
|
|||||||
{
|
{
|
||||||
int nodelay = *(FAR int *)value;
|
int nodelay = *(FAR int *)value;
|
||||||
|
|
||||||
if (!nodelay)
|
if ((!nodelay && option == TCP_NODELAY) ||
|
||||||
|
(nodelay && option == TCP_CORK))
|
||||||
{
|
{
|
||||||
nerr("ERROR: TCP_NODELAY not supported\n");
|
nerr("ERROR: %s not supported\n",
|
||||||
|
option == TCP_NODELAY ? "TCP_NODELAY" : "TCP_CORK");
|
||||||
ret = -ENOSYS;
|
ret = -ENOSYS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user