diff options
Diffstat (limited to 'lldb/source/Host/windows/HostThreadWindows.cpp')
-rw-r--r-- | lldb/source/Host/windows/HostThreadWindows.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lldb/source/Host/windows/HostThreadWindows.cpp b/lldb/source/Host/windows/HostThreadWindows.cpp index 5d526cc2530..02e3bf7c14e 100644 --- a/lldb/source/Host/windows/HostThreadWindows.cpp +++ b/lldb/source/Host/windows/HostThreadWindows.cpp @@ -36,21 +36,21 @@ Error HostThreadWindows::Join(lldb::thread_result_t *result) { Error error; - if (WAIT_OBJECT_0 != ::WaitForSingleObject(m_thread, INFINITE)) + if (IsJoinable()) { - error.SetError(::GetLastError(), lldb::eErrorTypeWin32); - return error; - } - - m_state = (m_state == eThreadStateCancelling) ? eThreadStateCancelled : eThreadStateExited; - - if (result) - { - DWORD dword_result = 0; - if (!::GetExitCodeThread(m_thread, &dword_result)) - *result = 0; - *result = dword_result; + DWORD wait_result = ::WaitForSingleObject(m_thread, INFINITE); + if (WAIT_OBJECT_0 == wait_result && result) + { + DWORD exit_code = 0; + if (!::GetExitCodeThread(m_thread, &exit_code)) + *result = 0; + *result = exit_code; + } + else if (WAIT_OBJECT_0 != wait_result) + error.SetError(::GetLastError(), eErrorTypeWin32); } + else + error.SetError(ERROR_INVALID_HANDLE, eErrorTypeWin32); return error; } |