]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests/server: fix initialization on Windows Vista+ master
authorViktor Szakats <commit@vsz.me>
Sun, 14 Dec 2025 23:05:15 +0000 (00:05 +0100)
committerViktor Szakats <commit@vsz.me>
Mon, 15 Dec 2025 01:14:28 +0000 (02:14 +0100)
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

tests/server/dnsd.c
tests/server/first.c
tests/server/mqttd.c
tests/server/resolve.c
tests/server/rtspd.c
tests/server/sockfilt.c
tests/server/socksd.c
tests/server/sws.c
tests/server/tftpd.c

index eaf56b03fbe6875498b2468a2af082d21a1bd5f3..949c9c12b3161314f5706410c77ab40cbbd9a9f8 100644 (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
index 0f30c7801620fca08b23f416d0d04519b1152789..60a1404bbb1d20ec52547e274359b54b6362a324 100644 (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);
 }
index 64ba64dc69ad65774bc8007329580093fd1c057d..cff3d497eac3d05e0d07b28502d5760edc1ad276 100644 (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);
index ed54eef5f36babd39b568cd688b890e90a7cbd05..3abcbcb33d63cc6567a2a6fa56bb9c3e5780be0e 100644 (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 */
index 6c7aa1e9d023ab5c4ac1fc9d18cc427254a7dab5..b343c79bd4675542e6f2591c8f8cc4b07fbd1d80 100644 (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
index db0261bf144dfdb7667214d6774baeefb8a8a1eb..01548f173d18cb9de9cbc9b9dfc7538588db2159 100644 (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);
index 99adb727fb9dc0dbe7642b7b511b453d821e7e2b..fdde648d3d288d732e5671a05abc3e23fcb0a767 100644 (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);
index c7ce24922418a78d2b4371ec3f450e565b4ae858..de0f096d467f194c28444990768176e0ac294c2e 100644 (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));
index d1867e7c872b2fd8c92b338ec53b51bb1866af54..8c40c40b34294ad0ce68d5b6dbea34ecadc59e1a 100644 (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