diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-08-09 14:29:54 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-08-09 20:15:43 +0200 |
commit | 8a0c43fa86bd32b4d47fd7e46d3ed414c9282ffa (patch) | |
tree | e86094b8f194d25c74157cf0df57b89a5c7d406b /ucbhelper | |
parent | da54fbce1c9101925059b980a0d9fe441bf0461f (diff) |
Use _beginthreadex instead of CreateThread
The documentation for ExitThread [1] has this comment:
A thread in an executable that calls the C run-time library (CRT) should use
the _beginthreadex and _endthreadex functions for thread management rather
than CreateThread and ExitThread; this requires the use of the multithreaded
version of the CRT. If a thread created using CreateThread calls the CRT,
the CRT may terminate the process in low-memory conditions.
Since ~all our code uses CRT, be safe and use _beginthreadex.
[1] https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createthread
Change-Id: If3e566592e921b00240e08aa759d8cdbc421d44b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155513
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'ucbhelper')
-rw-r--r-- | ucbhelper/source/client/proxydecider.cxx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ucbhelper/source/client/proxydecider.cxx b/ucbhelper/source/client/proxydecider.cxx index 862347465066..a46cfa268971 100644 --- a/ucbhelper/source/client/proxydecider.cxx +++ b/ucbhelper/source/client/proxydecider.cxx @@ -43,6 +43,7 @@ #define WIN32_LEAN_AND_MEAN #include <Windows.h> #include <Winhttp.h> +#include <process.h> #endif using namespace com::sun::star; @@ -460,7 +461,7 @@ struct GetPACProxyData // Tries to get proxy configuration using WinHttpGetProxyForUrl, which supports Web Proxy Auto-Discovery // (WPAD) protocol and manually configured address to get Proxy Auto-Configuration (PAC) file. // The WinINet/WinHTTP functions cannot correctly run in a STA COM thread, so use a dedicated thread -DWORD WINAPI GetPACProxyThread(_In_ LPVOID lpParameter) +unsigned __stdcall GetPACProxyThread(void* lpParameter) { assert(lpParameter); GetPACProxyData* pData = static_cast<GetPACProxyData*>(lpParameter); @@ -557,7 +558,8 @@ InternetProxyServer GetPACProxy(const OUString& rProtocol, const OUString& rHost } } - HANDLE hThread = CreateThread(nullptr, 0, GetPACProxyThread, &aData, 0, nullptr); + HANDLE hThread = reinterpret_cast<HANDLE>( + _beginthreadex(nullptr, 0, GetPACProxyThread, &aData, 0, nullptr)); if (hThread) { WaitForSingleObject(hThread, INFINITE); |