On Windows data can be lost in buffers in case of abnormal program
termination, especially in process chains as seen due to flaky tests.
Therefore flushing all buffers manually should avoid this data loss.
In the curl tool we play the safe game by only flushing write buffers,
but in the testsuite where we manage all buffers, we flush everything.
This should drastically reduce Windows CI and testsuite flakiness.
Reviewed-by: Daniel Stenberg
Supersedes #7833 and #6064
Closes #8516
main_free(&global);
}
+#ifdef WIN32
+ /* Flush buffers of all streams opened in write or update mode */
+ fflush(NULL);
+#endif
+
#ifdef __NOVELL_LIBC__
if(!getenv("_IN_NETWARE_BASH_"))
tool_pressanykey();
PR_Cleanup();
#endif
+#ifdef WIN32
+ /* flush buffers of all streams regardless of mode */
+ _flushall();
+#endif
+
return result;
}
fprintf(stderr, "%s: ", msg);
fprintf(stderr, "%s\n", buf);
}
-#endif /* WIN32 */
-#ifdef USE_WINSOCK
void win32_init(void)
{
+#ifdef USE_WINSOCK
WORD wVersionRequested;
WSADATA wsaData;
int err;
logmsg("No suitable winsock.dll found -- aborting");
exit(1);
}
+#endif /* USE_WINSOCK */
}
void win32_cleanup(void)
{
+#ifdef USE_WINSOCK
WSACleanup();
-}
#endif /* USE_WINSOCK */
+ /* flush buffers of all streams regardless of their mode */
+ _flushall();
+}
+#endif /* WIN32 */
+
/* set by the main code to point to where the test dir is */
const char *path = ".";
void win32_perror(const char *msg);
#endif /* WIN32 or _WIN32 */
-#ifdef USE_WINSOCK
+#ifdef WIN32
void win32_init(void);
void win32_cleanup(void);
-#endif /* USE_WINSOCK */
+#endif /* WIN32 */
/* fopens the test case file */
FILE *test2fopen(long testno);