Fix a threading-related crash in privacy consent recalculation.
Review Request #13322 — Created Oct. 9, 2023 and submitted
Under certain conditions, we recompute the privacy consent
registrations. This can happen on thread startup or teardown, and
occasionally, two threads end up interfering with each other's state.
This happens because, when recomputing, an unregister is performed, and
on a blank registry this will trigger a registry population, which then
triggers a signal and another attempt at a recomputation, in the middle
of an existing one. If this happens in multiple threads, it compounds
When this happens, we can end up triggering a double register of the new
consent requirements, which will crash.
We now surround all this with a threading lock, and check for this in
the signal handler to avoid triggering an extra recomputation.
Unit tests pass.
Consent requirements continue to work properly.