8000 Bug fix 3.2/fix thread shutdown (#7732) · arangodb/arangodb@c1e3fca · GitHub
[go: up one dir, main page]

Skip to content

Commit c1e3fca

Browse files
authored
Bug fix 3.2/fix thread shutdown (#7732)
1 parent 43259f3 commit c1e3fca

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
v3.2.18 (XXXX-XX-XX)
22
--------------------
33

4+
* fix thread shutdown in _WIN32 builds
5+
6+
Previous versions used a wrong comparison logic to determine the current
7+
thread id when shutting down a thread, leading to threads hanging in their
8+
destructors on thread shutdown
9+
410
* fixed TypeError being thrown instead of validation errors when Foxx manifest
511
validation fails
612

lib/Basics/threads-win32.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ bool TRI_StartThread(TRI_thread_t* thread, TRI_tid_t* threadId,
101101
////////////////////////////////////////////////////////////////////////////////
102102

103103
int TRI_JoinThread(TRI_thread_t* thread) {
104+
TRI_ASSERT(thread != nullptr);
104105
DWORD result = WaitForSingleObject(*thread, INFINITE);
105106

106107
switch (result) {
@@ -136,7 +137,8 @@ int TRI_JoinThread(TRI_thread_t* thread) {
136137
int TRI_DetachThread(TRI_thread_t* thread) {
137138
// If the function succeeds, the return value is nonzero.
138139
// If the function fails, the return value is zero. To get extended error information, call GetLastError.
139-
BOOL res = CloseHandle(thread);
140+
TRI_ASSERT(thread != nullptr);
141+
BOOL res = CloseHandle(*thread);
140142

141143
if (res == 0) {
142144
DWORD result = GetLastError();
@@ -157,7 +159,8 @@ bool TRI_IsSelfThread(TRI_thread_t* thread) {
157159
// TODO: Change the TRI_thread_t into a structure which stores the thread id
158160
// as well as the thread handle. This can then be passed around
159161
// ...........................................................................
160-
return (GetCurrentThreadId() == GetThreadId(thread));
162+
TRI_ASSERT(thread != nullptr);
163+
return (GetCurrentThreadId() == GetThreadId(*thread));
161164
}
162165

163166
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)
0