diff options
author | Yifan Hong <elsk@google.com> | 2023-12-06 19:47:44 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-12-06 19:47:44 +0000 |
commit | 3c969b5c1cc59b5c2592c5ef1f7425a7b63881eb (patch) | |
tree | 94bd250ae5aff812f2ba8f39a5ed74de7bf58956 | |
parent | 7a9ed3764d4dda00bc9e117025f887e769e8f141 (diff) | |
parent | c2d75ce4532029504eaf43c70b9907096f84d68e (diff) | |
download | native-3c969b5c1cc59b5c2592c5ef1f7425a7b63881eb.tar.gz |
Merge "lshal: do not pthread_kill" into main am: c2d75ce453
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2858054
Change-Id: If273ad1f3045a1bf7f90599494a721e0f9ca94f6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | cmds/lshal/Timeout.h | 10 | ||||
-rw-r--r-- | cmds/lshal/main.cpp | 1 |
2 files changed, 8 insertions, 3 deletions
diff --git a/cmds/lshal/Timeout.h b/cmds/lshal/Timeout.h index e8d22d9b58..012a5d54aa 100644 --- a/cmds/lshal/Timeout.h +++ b/cmds/lshal/Timeout.h @@ -72,10 +72,14 @@ bool timeout(std::chrono::duration<R, P> delay, std::function<void(void)> &&func return false; } bool success = state.wait(now + delay); - if (!success) { - pthread_kill(thread, SIGINT); + if (success) { + pthread_join(thread, nullptr); + } else { + // b/311143089: Abandon this background thread. Resources for a detached + // thread are cleaned up when it is terminated. If the background thread + // is stalled, it will be terminated when returning from main(). + pthread_detach(thread); } - pthread_join(thread, nullptr); return success; } diff --git a/cmds/lshal/main.cpp b/cmds/lshal/main.cpp index 366c9383a2..a44f467bb1 100644 --- a/cmds/lshal/main.cpp +++ b/cmds/lshal/main.cpp @@ -18,5 +18,6 @@ int main(int argc, char **argv) { using namespace ::android::lshal; + // Background pthreads from timeout() are destroyed upon returning from main(). return Lshal{}.main(Arg{argc, argv}); } |