From 83f7c08f653bbaa875c5c5cfa90031c232356928 Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Sun, 17 Jan 2021 11:58:57 +0800 Subject: [PATCH] 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 --- 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 88a2da157d..b864b19d68 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 3ddba92d0e..b4082ba2d9 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 */