diff options
author | Dmitriy Anisimkov <anisimko@adacore.com> | 2020-03-23 16:16:51 +0600 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-12 04:29:25 -0400 |
commit | e2b7399e34bab3aec45af99da7c31eb571f27f21 (patch) | |
tree | d1e4e4020baed15565a0bd63c0edd3063e160cbe /gcc/ada/socket.c | |
parent | 5052a270c0f685998a3456d87d441a59bc1d67ee (diff) | |
download | gcc-e2b7399e34bab3aec45af99da7c31eb571f27f21.zip gcc-e2b7399e34bab3aec45af99da7c31eb571f27f21.tar.gz gcc-e2b7399e34bab3aec45af99da7c31eb571f27f21.tar.bz2 |
[Ada] Don't correct socket timeout on Windows Server 2019
2020-06-12 Dmitriy Anisimkov <anisimko@adacore.com>
gcc/ada/
* socket.c (__gnat_minus_500ms): Use GetVersionEx to detect
Windows Server version.
* libgnat/g-sothco.ads (Minus_500ms_Windows_Timeout): Remade to
Boolean constant.
* libgnat/g-socket.adb (Set_Socket_Option): Use
Minus_500ms_Windows_Timeout constant instead of function call.
Diffstat (limited to 'gcc/ada/socket.c')
-rw-r--r-- | gcc/ada/socket.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/gcc/ada/socket.c b/gcc/ada/socket.c index 4e36790..dd73c6a 100644 --- a/gcc/ada/socket.c +++ b/gcc/ada/socket.c @@ -801,14 +801,26 @@ const char * __gnat_gai_strerror(int errcode) { int __gnat_minus_500ms() { #if defined (_WIN32) - // Windows 8.0 and newer do not need 500 millisecond socket timeout - // correction. - // We do not know the Windows server version without socket timeout - // correction for now. When we know, we can add the call for - // IsWindowsVersionOrGreater(10, 0, ????) into condition. - return !IsWindows8OrGreater() || IsWindowsServer(); + // Windows Server 2019 and Windows 8.0 do not need 500 millisecond socket + // timeout correction. + if (IsWindowsServer()) { + OSVERSIONINFO osvi; + ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + // Documentation proposes to use IsWindowsVersionOrGreater(10, 0, 17763) + // but it does not compare by the build number (last parameter). See + // regression test for RC03-012 in fixedbugs, there are some code to + // investigate Windows version API behavior. + GetVersionEx(&osvi); + return osvi.dwMajorVersion < 10 + || osvi.dwMajorVersion == 10 + && osvi.dwMinorVersion == 0 + && osvi.dwBuildNumber < 17763; + } else { + return !IsWindows8OrGreater(); + } #else - return 0; + return 0; #endif } |