From 1fc0617dccc3fa138235f219e2eaa7b405d1162e Mon Sep 17 00:00:00 2001 From: Jay Satiro Date: Fri, 24 Jan 2020 03:34:52 -0500 Subject: tool_util: Improve Windows version of tvnow() - Change tool_util.c tvnow() for Windows to match more closely to timeval.c Curl_now(). - Create a win32 init function for the tool, since some initialization is required for the tvnow() changes. Prior to this change the monotonic time function used by curl in Windows was determined at build-time and not runtime. That was a problem because when curl was built targeted for compatibility with old versions of Windows (eg _WIN32_WINNT < 0x0600) it would use GetTickCount which wraps every 49.7 days that Windows has been running. This change makes curl behave similar to libcurl's tvnow function, which determines at runtime whether the OS is Vista+ and if so calls QueryPerformanceCounter instead. (Note QueryPerformanceCounter is used because it has higher resolution than the more obvious candidate GetTickCount64). The changes to tvnow are basically a copy and paste but the types in some cases are different. Ref: https://github.com/curl/curl/issues/3309 Closes https://github.com/curl/curl/pull/4847 --- lib/system_win32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/system_win32.c') diff --git a/lib/system_win32.c b/lib/system_win32.c index 52a5fd951..7e287064e 100644 --- a/lib/system_win32.c +++ b/lib/system_win32.c @@ -109,11 +109,11 @@ CURLcode Curl_win32_init(long flags) if(Curl_verify_windows_version(6, 0, PLATFORM_WINNT, VERSION_GREATER_THAN_EQUAL)) { Curl_isVistaOrGreater = TRUE; - QueryPerformanceFrequency(&Curl_freq); } else Curl_isVistaOrGreater = FALSE; + QueryPerformanceFrequency(&Curl_freq); return CURLE_OK; } -- cgit v1.2.3