File 1449-ssh-alive-small-fixes.patch of Package erlang
From ce7728f97d41a8c816279ebe0243e5d62253088e Mon Sep 17 00:00:00 2001
From: Alexandre Rodrigues <alexandrejbr@live.com>
Date: Fri, 24 Oct 2025 16:24:45 +0200
Subject: [PATCH 19/20] ssh: alive small fixes
---
lib/ssh/doc/guides/hardening.md | 5 +++++
lib/ssh/src/ssh.hrl | 9 +++++----
lib/ssh/src/ssh_options.erl | 4 ++--
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/lib/ssh/doc/guides/hardening.md b/lib/ssh/doc/guides/hardening.md
index 6af69745b1..4122819469 100644
--- a/lib/ssh/doc/guides/hardening.md
+++ b/lib/ssh/doc/guides/hardening.md
@@ -91,6 +91,11 @@ increase the resilence. The options to use are:
the connection. The timeout is started when the authentication phase is
completed. It defaults to infinity.
+- **[alive](`t:ssh:alive_common_option/0`)** -
+ Sets the interval and the maximum number of alive messages that may be sent without
+ receiving any message back. Alive messages are typically used to detect that a connection
+ became unresponsive.
+
A figure clarifies when a timeout is started and when it triggers:

diff --git a/lib/ssh/src/ssh.hrl b/lib/ssh/src/ssh.hrl
index 414e666cad..5f010ceebc 100644
--- a/lib/ssh/src/ssh.hrl
+++ b/lib/ssh/src/ssh.hrl
@@ -546,13 +546,14 @@ protocol).
-type fd_common_option() :: {fd, gen_tcp:socket()} .
-doc """
-This option is used to configure the alive messages. Alive messages are sent through the encrypted
-channel and are typically used to detect that a connection became unresponsive.
+This option is used to configure the alive messages. Alive messages are sent
+through the encrypted channel and are typically used to detect that a
+connection became unresponsive.
-The `count_max` sets the maximum number
+`count_max` sets the maximum number
of alive messages which may be sent without receiving any messages back
from the peer. If this threshold is reached the connection will be terminated.
-The second value of the tuple sets the timeout interval, in seconds, after which, if no data
+`interval` sets a timeout interval, in milliseconds, after which, if no data
has been received from the peer, a message to request a response from the peer is sent.
The default is `#{count_max => 3, interval => infinity}`, which means that alive
diff --git a/lib/ssh/src/ssh_options.erl b/lib/ssh/src/ssh_options.erl
index 902ab0fd7c..d0d73a2f04 100644
--- a/lib/ssh/src/ssh_options.erl
+++ b/lib/ssh/src/ssh_options.erl
@@ -862,9 +862,9 @@ default(common) ->
alive =>
#{default => #{count_max => 3, interval => infinity},
- chk => fun(#{count_max := Count, interval := IntervalSeconds}) ->
+ chk => fun(#{count_max := Count, interval := Interval}) ->
check_pos_integer(Count) andalso
- check_timeout(IntervalSeconds)
+ check_timeout(Interval)
end,
class => user_option
},
--
2.51.0