From 497fa53db96a496f15170a3ae1c500ee3b1a7068 Mon Sep 17 00:00:00 2001 From: roynatech2544 Date: Fri, 7 Oct 2022 14:34:50 +0900 Subject: [PATCH] universal7885: parts-aidl: Swap changes * Remove join() call for std::thread which blocks the current context, halting the HAL thread also * access returns 0 on successful, so we should make file if return value isnt 0 * Set parts AIDL thread to 3, for SwapThread, other interactions, Binder transaction --- .../apps/aidl-support/parts/default/Swap.cpp | 8 +++----- .../apps/aidl-support/parts/default/service.cpp | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/universal7885-common/apps/aidl-support/parts/default/Swap.cpp b/universal7885-common/apps/aidl-support/parts/default/Swap.cpp index cd567e3..6819639 100644 --- a/universal7885-common/apps/aidl-support/parts/default/Swap.cpp +++ b/universal7885-common/apps/aidl-support/parts/default/Swap.cpp @@ -45,19 +45,17 @@ static bool swapOnRes = false; static void mkfile_swapon_thread(void) { const std::lock_guard lock(thread_lock); - if (access(SWAP_PATH, F_OK) == 0) { + if (access(SWAP_PATH, F_OK) != 0) { mkfile(mSwapSize * 10, SWAP_PATH); mkswap(SWAP_PATH); } - int res = - swapon(SWAP_PATH, (10 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK); + int res = swapon(SWAP_PATH, (10 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK); swapOnRes = res == 0; } ::ndk::ScopedAStatus SwapOnData::setSwapOn() { const std::lock_guard lock(thread_lock); std::thread mkswapfile(mkfile_swapon_thread); - mkswapfile.join(); return ::ndk::ScopedAStatus::ok(); } @@ -67,8 +65,8 @@ static void swapoff_thread(void) { } ::ndk::ScopedAStatus SwapOnData::setSwapOff() { + const std::lock_guard lock(thread_lock); std::thread swapoff(swapoff_thread); - swapoff.join(); return ::ndk::ScopedAStatus::ok(); } diff --git a/universal7885-common/apps/aidl-support/parts/default/service.cpp b/universal7885-common/apps/aidl-support/parts/default/service.cpp index 697c024..4cbf266 100644 --- a/universal7885-common/apps/aidl-support/parts/default/service.cpp +++ b/universal7885-common/apps/aidl-support/parts/default/service.cpp @@ -37,7 +37,7 @@ template static void registerAsService(std::shared_ptr service) { } int main() { - ABinderProcess_setThreadPoolMaxThreadCount(0); + ABinderProcess_setThreadPoolMaxThreadCount(3); registerAsService(ndk::SharedRefBase::make()); registerAsService(ndk::SharedRefBase::make());