Commit 3d0e9ea3 authored by rockot's avatar rockot Committed by Commit bot

[mojo-edk] Fix shutdown with old EDK.

The old EDK always initializes the new EDK as well, but it wasn't
shutting it down unless --use-new-edk was set. This was hitting
CHECKs to guard against double-initialization, because tests init
and shutdown the EDK multiple times in the same process.

This CL fixes that by always shutting the new EDK down as well.

Also we don't actually use g_io_thread_task_runner anymore so
I removed that.

TBRing since it's a pretty obvious fix IMHO and it's breaking
stuff on bots.

BUG=None
TBR=jam@chromium.org

Review URL: https://codereview.chromium.org/1642453002

Cr-Commit-Position: refs/heads/master@{#371748}
parent e3f31124
......@@ -29,7 +29,6 @@ class PlatformSupport;
namespace internal {
Core* g_core;
base::TaskRunner* g_io_thread_task_runner;
PlatformSupport* g_platform_support;
ProcessDelegate* g_process_delegate;
......@@ -101,10 +100,6 @@ MojoResult PassWrappedPlatformHandle(MojoHandle platform_handle_wrapper_handle,
void InitIPCSupport(ProcessDelegate* process_delegate,
scoped_refptr<base::TaskRunner> io_thread_task_runner) {
CHECK(internal::g_core);
CHECK(!internal::g_io_thread_task_runner);
internal::g_io_thread_task_runner = io_thread_task_runner.get();
internal::g_io_thread_task_runner->AddRef();
internal::g_core->SetIOTaskRunner(io_thread_task_runner);
internal::g_process_delegate = process_delegate;
}
......
......@@ -38,7 +38,6 @@ extern PlatformSupport* g_platform_support;
extern Core* g_core;
extern base::TaskRunner* g_delegate_thread_task_runner;
extern ProcessDelegate* g_process_delegate;
MOJO_SYSTEM_IMPL_EXPORT extern base::TaskRunner* g_io_thread_task_runner;
// TODO(use_chrome_edk): temporary until we have only one SDK.
MOJO_SYSTEM_IMPL_EXPORT Core* GetCore();
......
......@@ -229,35 +229,32 @@ void InitIPCSupport(ProcessType process_type,
}
void ShutdownIPCSupportOnIOThread() {
if (UseNewEDK()) {
mojo::edk::ShutdownIPCSupportOnIOThread();
return;
if (!UseNewEDK()) {
DCHECK(internal::g_ipc_support);
internal::g_ipc_support->ShutdownOnIOThread();
delete internal::g_ipc_support;
internal::g_ipc_support = nullptr;
delete g_wrapper_process_delegate;
g_wrapper_process_delegate = nullptr;
}
DCHECK(internal::g_ipc_support);
internal::g_ipc_support->ShutdownOnIOThread();
delete internal::g_ipc_support;
internal::g_ipc_support = nullptr;
delete g_wrapper_process_delegate;
g_wrapper_process_delegate = nullptr;
mojo::edk::ShutdownIPCSupportOnIOThread();
}
void ShutdownIPCSupport() {
if (UseNewEDK()) {
if (!UseNewEDK()) {
DCHECK(internal::g_ipc_support);
ProcessDelegate* delegate = internal::g_ipc_support->process_delegate();
bool ok = internal::g_ipc_support->io_thread_task_runner()->PostTaskAndReply(
FROM_HERE,
base::Bind(&ShutdownIPCSupportOnIOThread),
base::Bind(&ProcessDelegate::OnShutdownComplete,
base::Unretained(delegate)));
DCHECK(ok);
} else {
mojo::edk::ShutdownIPCSupport();
return;
}
DCHECK(internal::g_ipc_support);
ProcessDelegate* delegate = internal::g_ipc_support->process_delegate();
bool ok = internal::g_ipc_support->io_thread_task_runner()->PostTaskAndReply(
FROM_HERE,
base::Bind(&ShutdownIPCSupportOnIOThread),
base::Bind(&ProcessDelegate::OnShutdownComplete,
base::Unretained(delegate)));
DCHECK(ok);
}
ScopedMessagePipeHandle ConnectToSlave(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment