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/native_loader.cpp | |
parent | 84d462d8850067bd159495638ea522fa7c478e20 (diff) |
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/native_loader.cpp')
-rw-r--r-- | libnativeloader/native_loader.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
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__) |