diff options
| author | dimitry <dimitry@google.com> | 2018-09-12 01:09:19 +0200 |
|---|---|---|
| committer | dimitry <dimitry@google.com> | 2018-09-12 01:36:06 +0200 |
| commit | 3150f7c7af68c78e410c328b406223d748f9c7ba (patch) | |
| tree | f921b9f554b5094523ec8c059836e50610887bef /libnativeloader | |
| parent | 84d462d8850067bd159495638ea522fa7c478e20 (diff) | |
| download | system_core-3150f7c7af68c78e410c328b406223d748f9c7ba.tar.gz system_core-3150f7c7af68c78e410c328b406223d748f9c7ba.tar.bz2 system_core-3150f7c7af68c78e410c328b406223d748f9c7ba.zip | |
Add error_msg argument to CloseNativeLibrary
error_msg is set when dlclose/NativeBridgeUnloadLibrary fails.
Bug: https://issuetracker.google.com/79126103
Test: make
Change-Id: I043580209538ff47320e8d9a304a21c00c4b149f
Diffstat (limited to 'libnativeloader')
| -rw-r--r-- | libnativeloader/include/nativeloader/native_loader.h | 5 | ||||
| -rw-r--r-- | libnativeloader/native_loader.cpp | 18 |
2 files changed, 18 insertions, 5 deletions
diff --git a/libnativeloader/include/nativeloader/native_loader.h b/libnativeloader/include/nativeloader/native_loader.h index 19a17832e..c1d9d2a92 100644 --- a/libnativeloader/include/nativeloader/native_loader.h +++ b/libnativeloader/include/nativeloader/native_loader.h @@ -47,8 +47,9 @@ void* OpenNativeLibrary(JNIEnv* env, bool* needs_native_bridge, std::string* error_msg); -__attribute__((visibility("default"))) -bool CloseNativeLibrary(void* handle, const bool needs_native_bridge); +__attribute__((visibility("default"))) bool CloseNativeLibrary(void* handle, + const bool needs_native_bridge, + std::string* error_msg); #if defined(__ANDROID__) // Look up linker namespace by class_loader. Returns nullptr if diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp index 67c1c103b..b3e2b97fe 100644 --- a/libnativeloader/native_loader.cpp +++ b/libnativeloader/native_loader.cpp @@ -710,9 +710,21 @@ void* OpenNativeLibrary(JNIEnv* env, #endif } -bool CloseNativeLibrary(void* handle, const bool needs_native_bridge) { - return needs_native_bridge ? NativeBridgeUnloadLibrary(handle) : - dlclose(handle); +bool CloseNativeLibrary(void* handle, const bool needs_native_bridge, std::string* error_msg) { + bool success; + if (needs_native_bridge) { + success = (NativeBridgeUnloadLibrary(handle) == 0); + if (!success) { + *error_msg = NativeBridgeGetError(); + } + } else { + success = (dlclose(handle) == 0); + if (!success) { + *error_msg = dlerror(); + } + } + + return success; } #if defined(__ANDROID__) |
