Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(812)

Unified Diff: mojo/shell/in_process_dynamic_service_runner.cc

Issue 397733003: mojo: kill app_thread before unloading main app library and add tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: also service_manager_unittests Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/shell/in_process_dynamic_service_runner.h ('k') | mojo/shell/mojo_url_resolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/in_process_dynamic_service_runner.cc
diff --git a/mojo/shell/in_process_dynamic_service_runner.cc b/mojo/shell/in_process_dynamic_service_runner.cc
index 0d80d4096acdc13c8e526104d4604adff2405b40..834f20a4fe0411a21ee786ab1cc065d3c00fbb6b 100644
--- a/mojo/shell/in_process_dynamic_service_runner.cc
+++ b/mojo/shell/in_process_dynamic_service_runner.cc
@@ -9,7 +9,6 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "base/scoped_native_library.h"
#include "mojo/public/platform/native/system_thunks.h"
namespace mojo {
@@ -26,6 +25,11 @@ InProcessDynamicServiceRunner::~InProcessDynamicServiceRunner() {
DCHECK(!thread_.HasBeenJoined());
thread_.Join();
}
+
+ // It is important to let the thread exit before unloading the DSO because
+ // the library may have registered thread-local data and destructors to run
+ // on thread termination.
+ app_library_.Reset(base::NativeLibrary());
}
void InProcessDynamicServiceRunner::Start(
@@ -53,16 +57,15 @@ void InProcessDynamicServiceRunner::Run() {
do {
base::NativeLibraryLoadError error;
- base::ScopedNativeLibrary app_library(
- base::LoadNativeLibrary(app_path_, &error));
- if (!app_library.is_valid()) {
+ app_library_.Reset(base::LoadNativeLibrary(app_path_, &error));
+ if (!app_library_.is_valid()) {
LOG(ERROR) << "Failed to load app library (error: " << error.ToString()
<< ")";
break;
}
MojoSetSystemThunksFn mojo_set_system_thunks_fn =
- reinterpret_cast<MojoSetSystemThunksFn>(app_library.GetFunctionPointer(
+ reinterpret_cast<MojoSetSystemThunksFn>(app_library_.GetFunctionPointer(
"MojoSetSystemThunks"));
if (mojo_set_system_thunks_fn) {
MojoSystemThunks system_thunks = MojoMakeSystemThunks();
@@ -84,7 +87,7 @@ void InProcessDynamicServiceRunner::Run() {
typedef MojoResult (*MojoMainFunction)(MojoHandle);
MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>(
- app_library.GetFunctionPointer("MojoMain"));
+ app_library_.GetFunctionPointer("MojoMain"));
if (!main_function) {
LOG(ERROR) << "Entrypoint MojoMain not found";
break;
« no previous file with comments | « mojo/shell/in_process_dynamic_service_runner.h ('k') | mojo/shell/mojo_url_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698