From: Dmitriy Anisimkov Date: Wed, 19 May 2021 12:26:16 +0000 (+0600) Subject: [Ada] Timeout correction on Get_Socket_Option X-Git-Tag: basepoints/gcc-13~6198 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fa7097a140f007f86e81f62cd08fff15b16ef6e;p=thirdparty%2Fgcc.git [Ada] Timeout correction on Get_Socket_Option gcc/ada/ * libgnat/g-socket.adb (Get_Socket_Option): Add 500ms only when Minus_500ms_Windows_Timeout is True. (Set_Socket_Option): Use "* 1000" instead of "/ 0.001" to convert to milliseconds. --- diff --git a/gcc/ada/libgnat/g-socket.adb b/gcc/ada/libgnat/g-socket.adb index a246303cb66c..75a2b27414fe 100644 --- a/gcc/ada/libgnat/g-socket.adb +++ b/gcc/ada/libgnat/g-socket.adb @@ -1570,14 +1570,18 @@ package body GNAT.Sockets is | Send_Timeout => if Is_Windows then - - -- Timeout is in milliseconds, actual value is 500 ms + - -- returned value (unless it is 0). - if U4 = 0 then Opt.Timeout := 0.0; + else - Opt.Timeout := Duration (U4) / 1000 + 0.500; + if Minus_500ms_Windows_Timeout then + -- Timeout is in milliseconds, actual value is 500 ms + + -- returned value (unless it is 0). + + U4 := U4 + 500; + end if; + + Opt.Timeout := Duration (U4) / 1000; end if; else @@ -2724,7 +2728,7 @@ package body GNAT.Sockets is Len := U4'Size / 8; Add := U4'Address; - U4 := C.unsigned (Option.Timeout / 0.001); + U4 := C.unsigned (Option.Timeout * 1000); if Option.Timeout > 0.0 and then U4 = 0 then -- Avoid round to zero. Zero timeout mean unlimited