You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gu...@apache.org on 2021/07/13 12:44:27 UTC
[incubator-nuttx] branch master updated: net/tcp: only print the
error when disable the TCP_NODELAY
This is an automated email from the ASF dual-hosted git repository.
gustavonihei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 83f7c08 net/tcp: only print the error when disable the TCP_NODELAY
83f7c08 is described below
commit 83f7c08f653bbaa875c5c5cfa90031c232356928
Author: chao.an <an...@xiaomi.com>
AuthorDate: Sun Jan 17 11:58:57 2021 +0800
net/tcp: only print the error when disable the TCP_NODELAY
Since we do not have the Nagle's algorithm,
the TCP_NODELAY socket option is enabled by default.
Change-Id: I0c8619bb06cf418f7eded5bd72ac512b349cacc5
Signed-off-by: chao.an <an...@xiaomi.com>
---
net/tcp/tcp_getsockopt.c | 16 ++++++++++++++--
net/tcp/tcp_setsockopt.c | 20 ++++++++++++++++++--
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/net/tcp/tcp_getsockopt.c b/net/tcp/tcp_getsockopt.c
index 88a2da1..b864b19 100644
--- a/net/tcp/tcp_getsockopt.c
+++ b/net/tcp/tcp_getsockopt.c
@@ -139,8 +139,20 @@ int tcp_getsockopt(FAR struct socket *psock, int option,
break;
case TCP_NODELAY: /* Avoid coalescing of small segments. */
- nerr("ERROR: TCP_NODELAY not supported\n");
- ret = -ENOSYS;
+ 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 */
diff --git a/net/tcp/tcp_setsockopt.c b/net/tcp/tcp_setsockopt.c
index 3ddba92..b4082ba 100644
--- a/net/tcp/tcp_setsockopt.c
+++ b/net/tcp/tcp_setsockopt.c
@@ -133,8 +133,24 @@ int tcp_setsockopt(FAR struct socket *psock, int option,
break;
case TCP_NODELAY: /* Avoid coalescing of small segments. */
- nerr("ERROR: TCP_NODELAY not supported\n");
- ret = -ENOSYS;
+ if (value_len != sizeof(int))
+ {
+ ret = -EDOM;
+ }
+ else
+ {
+ int nodelay = *(FAR int *)value;
+
+ if (nodelay)
+ {
+ ret = OK;
+ }
+ else
+ {
+ nerr("ERROR: TCP_NODELAY not supported\n");
+ ret = -ENOSYS;
+ }
+ }
break;
case TCP_KEEPIDLE: /* Start keepalives after this IDLE period */