Fixes two data races in USAP pool management.

The USAP pool management code contained two data races.  One could cause
a double decrement if a runtime thread executed the SIGCHLD handler
while the server was responding to a pool exit message from a USAP.  The
other data race could occur when the SIGCHLD handler executed in the
middle of a USAP pool flush.

The solution to the first race is to change the return value from a
helper function to ensure that the decrement only occurs when the entry
is invalidated through that specific invocation of the helper.

The second data race was fixed by using SIGTERM instead of SIGKILL when
flushing the USAP pool.  This allows the Zygote to clear the table
entries outside of the SIGCHLD handler, and the handler to avoid
duplicate bookkeeping cleanup when this occurs.  SIGTERM is used so that
it can be differentiated from other process termination events and so
that it can be blocked while the USAP is specializing, but hasn't yet
informed the Zygote of it's removal from the pool.  This issue and this
fix will no longer be necessary once the Zygote signal handler has been
replaced with a signalfd.

Bug: 132794985
Test: atest SignedConfigHostTest
Change-Id: Ie01637a10b356b80b5aa62291a97f2c167242827
Merged-In: Ie01637a10b356b80b5aa62291a97f2c167242827
(cherry picked from commit fb329ba7c858bd73f5a57b2b700c5d042ab8675d)
3 files changed