Merge "storageproxyd: Start binder thread pool" into main am: fe1fa35823 am: 3fbf1e39e7 am: d629c4e04e

Original change: https://android-review.googlesource.com/c/platform/system/core/+/2660288

Change-Id: I65d8a88239c659b4bd14b86bc486aaa7fd0a76a7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2023-07-20 01:04:12 +00:00 committed by Automerger Merge Worker
commit b26bf3e48e
3 changed files with 19 additions and 0 deletions

View file

@ -33,6 +33,7 @@ cc_binary {
shared_libs: [
"libbase",
"libbinder_ndk",
"libcutils",
"liblog",
"libhardware_legacy",

View file

@ -24,6 +24,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <android/binder_process.h>
#include <cutils/android_filesystem_config.h>
#include "checkpoint_handling.h"
@ -238,6 +239,15 @@ int main(int argc, char* argv[]) {
/* parse arguments */
parse_args(argc, argv);
/*
* Start binder threadpool. At least one extra binder thread is needed to
* connect to the wakelock service without relying on polling. If we poll on
* the main thread we end up pausing for at least 1s even if the service
* starts faster.
*/
ABinderProcess_setThreadPoolMaxThreadCount(1);
ABinderProcess_startThreadPool();
/* initialize secure storage directory */
rc = storage_init(ss_data_root);
if (rc < 0) return EXIT_FAILURE;

View file

@ -399,6 +399,14 @@ static int send_ufs_rpmb_req(int sg_fd, const struct storage_rpmb_send_req* req,
bool is_request_write = req->reliable_write_size > 0;
/*
* Internally this call connects to the suspend service, which will cause
* this service to start if not already running. If the binder thread pool
* has not been started at this point, this call will block and poll for the
* service every 1s. We need to make sure the thread pool is started to
* receive an async notification that the service is started to avoid
* blocking (see main).
*/
wl_rc = acquire_wake_lock(PARTIAL_WAKE_LOCK, UFS_WAKE_LOCK_NAME);
if (wl_rc < 0) {
ALOGE("%s: failed to acquire wakelock: %d, %s\n", __func__, wl_rc, strerror(errno));