summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2021-11-29 08:00:57 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2021-11-29 08:00:57 +0000
commit9078248b754c00499cc13a5e3cc6aba719b93357 (patch)
treeb30fbb52cf834145909ef91c569b4dac5925aa9c
parentfc7e697e4c19be0ff3191128c0fe2893a6c0b393 (diff)
parentfaf1b1cf0b6c7e343df4cb6428cd7f6b16db25d3 (diff)
Merge "Fix an issue when empty the usap pool." am: faf1b1cf0b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1893002 Change-Id: I6d5e04471f756ee5544bb1f77cf1927f44d7715a
-rw-r--r--core/java/com/android/internal/os/Zygote.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
index 92d5a47a2ed0..6d4b8c5ea1ad 100644
--- a/core/java/com/android/internal/os/Zygote.java
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -724,9 +724,6 @@ public final class Zygote {
DataOutputStream usapOutputStream = null;
ZygoteArguments args = null;
- // Block SIGTERM so we won't be killed if the Zygote flushes the USAP pool.
- blockSigTerm();
-
LocalSocket sessionSocket = null;
if (argBuffer == null) {
// Read arguments from usapPoolSocket instead.
@@ -742,6 +739,10 @@ public final class Zygote {
ZygoteCommandBuffer tmpArgBuffer = null;
try {
sessionSocket = usapPoolSocket.accept();
+ // Block SIGTERM so we won't be killed if the Zygote flushes the USAP pool.
+ // This is safe from a race condition because the pool is only flushed after
+ // the SystemServer changes its internal state to stop using the USAP pool.
+ blockSigTerm();
usapOutputStream =
new DataOutputStream(sessionSocket.getOutputStream());
@@ -759,9 +760,10 @@ public final class Zygote {
unblockSigTerm();
IoUtils.closeQuietly(sessionSocket);
IoUtils.closeQuietly(tmpArgBuffer);
- blockSigTerm();
}
} else {
+ // Block SIGTERM so we won't be killed if the Zygote flushes the USAP pool.
+ blockSigTerm();
try {
args = ZygoteArguments.getInstance(argBuffer);
} catch (Exception ex) {