Add magic to fctxcount and replace the atomics with integers

Ondřej Surý requested to merge 3814-tighten-the-locking-around-fctxcount into main

Add magic value to the fctxcount, to check for completely invalid counters, or counters that have been already destroyed.

Improve the locking around the counters, and because of that we can drop the atomics and use simple integers - the counters were already locked and the tiny bits that used the atomics were not worth the extra effort.

Closes #3814 (closed)

Merge request reports