public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2105] [Ada] Add socket options to control keepalive on TCP connection
@ 2021-07-07 16:24 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-07-07 16:24 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f3ff72939e52a381d28f3c4879f2eaa1d154ff73
commit r12-2105-gf3ff72939e52a381d28f3c4879f2eaa1d154ff73
Author: Dmitriy Anisimkov <anisimko@adacore.com>
Date: Tue May 18 11:03:31 2021 +0600
[Ada] Add socket options to control keepalive on TCP connection
gcc/ada/
* libgnat/g-socket.ads (Option_Name): Add Keep_Alive_Count,
Keep_Alive_Idle, and Keep_Alive_Interval items to enumeration.
(Option_Type): Add Keep_Alive_Count, Keep_Alive_Idle, and
Keep_Alive_Interval alternatives to the case of discriminated
record.
* libgnat/g-socket.adb (Options): Add Keep_Alive_Count,
Keep_Alive_Idle, and Keep_Alive_Interval to items enumerator to
OS constant converter.
(Set_Socket_Option): Process Keep_Alive_Count, Keep_Alive_Idle,
and Keep_Alive_Interval socket options.
(Get_Socket_Option): Idem.
Diff:
---
gcc/ada/libgnat/g-socket.adb | 30 +++++++++++++++++++++++++++++
gcc/ada/libgnat/g-socket.ads | 46 ++++++++++++++++++++++++++++++--------------
2 files changed, 62 insertions(+), 14 deletions(-)
diff --git a/gcc/ada/libgnat/g-socket.adb b/gcc/ada/libgnat/g-socket.adb
index ec4cf29d42f..a246303cb66 100644
--- a/gcc/ada/libgnat/g-socket.adb
+++ b/gcc/ada/libgnat/g-socket.adb
@@ -96,6 +96,9 @@ package body GNAT.Sockets is
Options : constant array (Specific_Option_Name) of C.int :=
(Keep_Alive => SOSC.SO_KEEPALIVE,
+ Keep_Alive_Count => SOSC.TCP_KEEPCNT,
+ Keep_Alive_Idle => SOSC.TCP_KEEPIDLE,
+ Keep_Alive_Interval => SOSC.TCP_KEEPINTVL,
Reuse_Address => SOSC.SO_REUSEADDR,
Broadcast => SOSC.SO_BROADCAST,
Send_Buffer => SOSC.SO_SNDBUF,
@@ -1442,6 +1445,9 @@ package body GNAT.Sockets is
| Error
| Generic_Option
| Keep_Alive
+ | Keep_Alive_Count
+ | Keep_Alive_Idle
+ | Keep_Alive_Interval
| Multicast_If_V4
| Multicast_If_V6
| Multicast_Loop_V4
@@ -1511,6 +1517,15 @@ package body GNAT.Sockets is
=>
Opt.Enabled := (V4 /= 0);
+ when Keep_Alive_Count =>
+ Opt.Count := Natural (V4);
+
+ when Keep_Alive_Idle =>
+ Opt.Idle_Seconds := Natural (V4);
+
+ when Keep_Alive_Interval =>
+ Opt.Interval_Seconds := Natural (V4);
+
when Busy_Polling =>
Opt.Microseconds := Natural (V4);
@@ -2620,6 +2635,21 @@ package body GNAT.Sockets is
Len := V4'Size / 8;
Add := V4'Address;
+ when Keep_Alive_Count =>
+ V4 := C.int (Option.Count);
+ Len := V4'Size / 8;
+ Add := V4'Address;
+
+ when Keep_Alive_Idle =>
+ V4 := C.int (Option.Idle_Seconds);
+ Len := V4'Size / 8;
+ Add := V4'Address;
+
+ when Keep_Alive_Interval =>
+ V4 := C.int (Option.Interval_Seconds);
+ Len := V4'Size / 8;
+ Add := V4'Address;
+
when Busy_Polling =>
V4 := C.int (Option.Microseconds);
Len := V4'Size / 8;
diff --git a/gcc/ada/libgnat/g-socket.ads b/gcc/ada/libgnat/g-socket.ads
index 03afd3691c2..4372f3eace7 100644
--- a/gcc/ada/libgnat/g-socket.ads
+++ b/gcc/ada/libgnat/g-socket.ads
@@ -845,11 +845,20 @@ package GNAT.Sockets is
-- IP_Protocol_For_TCP_Level --
-------------------------------
- No_Delay, -- TCP_NODELAY
+ No_Delay, -- TCP_NODELAY
-- Disable the Nagle algorithm. This means that output buffer content
-- is always sent as soon as possible, even if there is only a small
-- amount of data.
+ Keep_Alive_Count, -- TCP_KEEPCNT
+ -- Maximum number of keepalive probes
+
+ Keep_Alive_Idle, -- TCP_KEEPIDLE
+ -- Idle time before TCP starts sending keepalive probes
+
+ Keep_Alive_Interval, -- TCP_KEEPINTVL
+ -- Time between individual keepalive probes
+
------------------------------
-- IP_Protocol_For_IP_Level --
------------------------------
@@ -923,26 +932,35 @@ package GNAT.Sockets is
Enabled : Boolean;
case Name is
- when Linger =>
+ when Linger =>
Seconds : Natural;
- when others =>
+ when others =>
null;
end case;
- when Busy_Polling =>
+ when Keep_Alive_Count =>
+ Count : Natural;
+
+ when Keep_Alive_Idle =>
+ Idle_Seconds : Natural;
+
+ when Keep_Alive_Interval =>
+ Interval_Seconds : Natural;
+
+ when Busy_Polling =>
Microseconds : Natural;
- when Send_Buffer |
- Receive_Buffer =>
+ when Send_Buffer |
+ Receive_Buffer =>
Size : Natural;
- when Error =>
+ when Error =>
Error : Error_Type;
- when Add_Membership_V4 |
- Add_Membership_V6 |
- Drop_Membership_V4 |
- Drop_Membership_V6 =>
+ when Add_Membership_V4 |
+ Add_Membership_V6 |
+ Drop_Membership_V4 |
+ Drop_Membership_V6 =>
Multicast_Address : Inet_Addr_Type;
case Name is
when Add_Membership_V4 |
@@ -958,13 +976,13 @@ package GNAT.Sockets is
when Multicast_If_V6 =>
Outgoing_If_Index : Natural;
- when Multicast_TTL =>
+ when Multicast_TTL =>
Time_To_Live : Natural;
- when Multicast_Hops =>
+ when Multicast_Hops =>
Hop_Limit : Integer range -1 .. 255;
- when Send_Timeout |
+ when Send_Timeout |
Receive_Timeout =>
Timeout : Timeval_Duration;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-07 16:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 16:24 [gcc r12-2105] [Ada] Add socket options to control keepalive on TCP connection Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).