tests/server: fix initialization on Windows Vista+

Make sure to call `curlx_now_init()` before the first call to
`curlx_now()`.

Before this patch the first `curlx_now()` used the non-Vista code path
calling `GetTickCount()` on Vista+. This is harmless, but the upcoming
PR #18009 is going to drop the non-Vista code path, causing a division
by zero at startup in test servers, without this fix.

Bug: https://github.com/curl/curl/pull/18009#issuecomment-3652154307

Closes #19973
This commit is contained in:
Viktor Szakats
2025-12-15 00:05:15 +01:00
parent 2399ec74c3
commit b10b7c1fce
9 changed files with 5 additions and 40 deletions

View File

@@ -474,11 +474,6 @@ static int test_dnsd(int argc, char **argv)
snprintf(loglockfile, sizeof(loglockfile), "%s/%s/dnsd-%s.lock",
logdir, SERVERLOGS_LOCKDIR, ipv_inuse);
#ifdef _WIN32
if(win32_init())
return 2;
#endif
#ifdef USE_IPV6
if(!use_ipv6)
#endif

View File

@@ -51,5 +51,10 @@ int main(int argc, char **argv)
return 99;
}
#ifdef _WIN32
if(win32_init())
return 2;
#endif
return entry_func(argc - 1, argv + 1);
}

View File

@@ -822,11 +822,6 @@ static int test_mqttd(int argc, char *argv[])
snprintf(loglockfile, sizeof(loglockfile), "%s/%s/mqtt-%s.lock",
logdir, SERVERLOGS_LOCKDIR, ipv_inuse);
#ifdef _WIN32
if(win32_init())
return 2;
#endif
CURLX_SET_BINMODE(stdin);
CURLX_SET_BINMODE(stdout);
CURLX_SET_BINMODE(stderr);

View File

@@ -83,11 +83,6 @@ static int test_resolve(int argc, char *argv[])
return 1;
}
#ifdef _WIN32
if(win32_init())
return 2;
#endif
#ifdef CURLRES_IPV6
if(use_ipv6) {
/* Check that the system has IPv6 enabled before checking the resolver */

View File

@@ -1100,11 +1100,6 @@ static int test_rtspd(int argc, char *argv[])
snprintf(loglockfile, sizeof(loglockfile), "%s/%s/rtsp-%s.lock",
logdir, SERVERLOGS_LOCKDIR, ipv_inuse);
#ifdef _WIN32
if(win32_init())
return 2;
#endif
install_signal_handlers(false);
#ifdef USE_IPV6

View File

@@ -1313,11 +1313,6 @@ static int test_sockfilt(int argc, char *argv[])
}
}
#ifdef _WIN32
if(win32_init())
return 2;
#endif
CURLX_SET_BINMODE(stdin);
CURLX_SET_BINMODE(stdout);
CURLX_SET_BINMODE(stderr);

View File

@@ -875,11 +875,6 @@ static int test_socksd(int argc, char *argv[])
}
}
#ifdef _WIN32
if(win32_init())
return 2;
#endif
CURLX_SET_BINMODE(stdin);
CURLX_SET_BINMODE(stdout);
CURLX_SET_BINMODE(stderr);

View File

@@ -2159,11 +2159,6 @@ static int test_sws(int argc, char *argv[])
logdir, SERVERLOGS_LOCKDIR, protocol_type,
is_proxy ? "-proxy" : "", socket_type);
#ifdef _WIN32
if(win32_init())
return 2;
#endif
install_signal_handlers(false);
req = calloc(1, sizeof(*req));

View File

@@ -647,11 +647,6 @@ static int test_tftpd(int argc, char **argv)
snprintf(loglockfile, sizeof(loglockfile), "%s/%s/tftp-%s.lock",
logdir, SERVERLOGS_LOCKDIR, ipv_inuse);
#ifdef _WIN32
if(win32_init())
return 2;
#endif
install_signal_handlers(true);
#ifdef USE_IPV6