8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 21:23:03 +01:00

Merge pull request #296 from jmglogow/fix-win-thread-handle-type

Fix Thread handle type on Windows
This commit is contained in:
Vlad Khorsun 2020-12-02 11:14:27 +02:00 committed by GitHub
commit bf3dc9b08c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -309,13 +309,16 @@ Thread Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, Han
* Advanced Windows by Richter pg. # 109. */
unsigned thread_id;
unsigned long real_handle =
_beginthreadex(NULL, 0, THREAD_ENTRYPOINT, THREAD_ARG, CREATE_SUSPENDED, &thread_id);
if (!real_handle)
HANDLE handle =
reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0, THREAD_ENTRYPOINT, THREAD_ARG, CREATE_SUSPENDED, &thread_id));
if (!handle)
{
// Though MSDN says that _beginthreadex() returns error in errno,
// GetLastError() still works because RTL call no other system
// functions after CreateThread() in the case of error.
// Watch out if it is ever changed.
Firebird::system_call_failed::raise("_beginthreadex", GetLastError());
}
HANDLE handle = reinterpret_cast<HANDLE>(real_handle);
SetThreadPriority(handle, priority);