diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc index 163e1c378e..63c8f65351 100644 --- a/rtc_base/platform_thread.cc +++ b/rtc_base/platform_thread.cc @@ -129,8 +129,15 @@ void PlatformThread::Stop() { #if defined(WEBRTC_WIN) // Set stop_ to |true| on the worker thread. bool queued = QueueAPC(&RaiseFlag, reinterpret_cast(&stop_)); - // Queuing the APC can fail if the thread is being terminated. - RTC_CHECK(queued || GetLastError() == ERROR_GEN_FAILURE); + if (!queued) { + // Queuing the APC can fail if the thread is being terminated. This should + // return ERROR_GEN_FAILURE, though Wine returns ERROR_ACCESS_DENIED, so + // allow for either. + auto error = ::GetLastError(); + if (error != ERROR_GEN_FAILURE && error != ERROR_ACCESS_DENIED) { + RTC_CHECK(false) << "Failed to QueueUserAPC, error: " << error; + } + } WaitForSingleObject(thread_, INFINITE); CloseHandle(thread_); thread_ = nullptr;