Fix incorrect thread pool in rkpd
ThreadPoolExecutor will only spin up new threads if the queue is full,
otherwise, it will wait for worker threads to come available to fulfill
work. Since the pool had an unbounded queue, our workers were always
queuing up to wait on just one worker thread.
Use a fixed thread pool so we'll spin up as many threads as cores to
satisfy work requests.
Also synchronize the Provisioner so that we never have two threads
hitting the network at the same time. This was the old behavior,
since all provisioning happened on the threadpool anyway. Let's keep that for consistency with existing behavior. Otherwise, in edge
cases, we could end up provisioning twice as many keys as we need.
Lastly: fix up a minor bug in the stress test that was keeping it from
running. We've missed this because that test isn't part of any automation, but it's a great test for validating this fix.
Bug: 281902467
Test: RkpdAppIntegrationTests RkpdAppUnitTests RkpdAppStressTests
Test: keystore2_test
(cherry picked from https://android-review.googlesource.com/q/commit:85a29a5247997595e2961095c3d5edcca15566e6)
Merged-In: I5a4d9c0fa53beb9cf8bf951f495f2fd60d7cb609
Change-Id: I5a4d9c0fa53beb9cf8bf951f495f2fd60d7cb609
3 files changed