From 72f2eb6800be42758cbe86f9b191e5b2c5859197 Mon Sep 17 00:00:00 2001 From: roynatech2544 Date: Tue, 11 Oct 2022 21:21:57 +0900 Subject: [PATCH] universal7885: parts-aidl: Unlock mutex if try_lock() returned true try_lock() returns instantly, but it does acquires mutex lock if it is avaliable. If we just return try_lock() result, mutex is still locked by the thread. So it results in forever false with try_lock(). If the try_lock() returns true, unlock and return true for fix --- .../apps/aidl-support/parts/default/Swap.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/universal7885-common/apps/aidl-support/parts/default/Swap.cpp b/universal7885-common/apps/aidl-support/parts/default/Swap.cpp index 4a19e97..d488000 100644 --- a/universal7885-common/apps/aidl-support/parts/default/Swap.cpp +++ b/universal7885-common/apps/aidl-support/parts/default/Swap.cpp @@ -92,7 +92,12 @@ static void swapoff_func(void) { } ::ndk::ScopedAStatus SwapOnData::isMutexLocked(bool *_aidl_return) { - *_aidl_return = !thread_lock.try_lock(); + if (thread_lock.try_lock()) { + thread_lock.unlock(); + *_aidl_return = false; + } else { + *_aidl_return = true; + } return ::ndk::ScopedAStatus::ok(); }