From 753aa98ca712c5ef83685363060307c172c04b94 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 19 May 2022 01:59:12 +0800 Subject: [PATCH] net/tcp: Zero keeptimer in case caller set keepalive to false Signed-off-by: Xiang Xiao --- net/tcp/tcp_setsockopt.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/net/tcp/tcp_setsockopt.c b/net/tcp/tcp_setsockopt.c index 402b0e3e94..600a14aeaa 100644 --- a/net/tcp/tcp_setsockopt.c +++ b/net/tcp/tcp_setsockopt.c @@ -129,11 +129,8 @@ int tcp_setsockopt(FAR struct socket *psock, int option, /* Reset timer */ - if (conn->keepalive) - { - conn->keeptimer = conn->keepidle; - conn->keepretries = 0; - } + conn->keeptimer = keepalive ? conn->keepidle : 0; + conn->keepretries = 0; } } break;