mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-21 22:47:42 +01:00
Fix server thread assertion on CEF shutdown (see issue #2969)
The server thread was not guaranteed to be released in the correct scope on CEF shutdown. This resulted in occasional thread_restrictions assertions on ceftests shutdown after running the URLRequestTest suite with the Chrome runtime enabled.
This commit is contained in:
parent
09a9d9b54c
commit
c565d9b1e6
@ -595,7 +595,7 @@ void CefServerImpl::ShutdownOnUIThread() {
|
|||||||
if (thread_) {
|
if (thread_) {
|
||||||
// Stop the handler thread as a background task so the UI thread isn't
|
// Stop the handler thread as a background task so the UI thread isn't
|
||||||
// blocked.
|
// blocked.
|
||||||
CEF_POST_BACKGROUND_TASK(BindOnce(
|
auto task = base::BindOnce(
|
||||||
[](std::unique_ptr<base::Thread> thread) {
|
[](std::unique_ptr<base::Thread> thread) {
|
||||||
// Calling PlatformThread::Join() on the UI thread is otherwise
|
// Calling PlatformThread::Join() on the UI thread is otherwise
|
||||||
// disallowed.
|
// disallowed.
|
||||||
@ -603,7 +603,15 @@ void CefServerImpl::ShutdownOnUIThread() {
|
|||||||
scoped_allow_sync_primitives;
|
scoped_allow_sync_primitives;
|
||||||
thread.reset();
|
thread.reset();
|
||||||
},
|
},
|
||||||
std::move(thread_)));
|
std::move(thread_));
|
||||||
|
|
||||||
|
// Make sure the task is executed on shutdown. Otherwise, |thread| might
|
||||||
|
// be released outside of the correct scope.
|
||||||
|
base::PostTask(
|
||||||
|
FROM_HERE,
|
||||||
|
{base::ThreadPool(), base::TaskPriority::BEST_EFFORT,
|
||||||
|
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()},
|
||||||
|
std::move(task));
|
||||||
|
|
||||||
// Release the reference that was added in StartupOnUIThread().
|
// Release the reference that was added in StartupOnUIThread().
|
||||||
Release();
|
Release();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user