Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/tcp: Fix TCP keepalive time unit misuse problem #13589

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions net/tcp/tcp_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,15 @@ static int tcp_get_timeout(FAR struct tcp_conn_s *conn)
#ifdef CONFIG_NET_TCP_KEEPALIVE
if (timeout == 0)
{
timeout = conn->keeptimer;
/* The conn->keeptimer units is decisecond and the timeout
* units is half-seconds, therefore they need to be unified.
*/

timeout = conn->keeptimer / DSEC_PER_HSEC;
}
else if (conn->keeptimer > 0 && timeout > conn->keeptimer)
else if (conn->keeptimer > 0 && timeout > conn->keeptimer / DSEC_PER_HSEC)
{
timeout = conn->keeptimer;
timeout = conn->keeptimer / DSEC_PER_HSEC;
}
#endif

Expand Down Expand Up @@ -699,11 +703,11 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
* received from the remote peer?
*/

if (conn->keeptimer > hsec)
if (conn->keeptimer > hsec * DSEC_PER_HSEC)
{
/* Will not yet decrement to zero */

conn->keeptimer -= hsec;
conn->keeptimer -= hsec * DSEC_PER_HSEC;
}
else
{
Expand Down
Loading