lxd/main_forkfile: Change counting model
lxd/main_forkfile: Change counting model

The use of CompareAndSwap from the atomic package is causing a large
number of EAGAIN during the accept phase of connection handling.
This in turn results in a number of "Connection reset by peer".

Instead change the logic to rely on more traditional locks and counters,
combined with a grace period of 5s, this gives us a pretty solid
auto-exit behavior.

Closes #10448

Signed-off-by: Stéphane Graber <089afc6d81f66f1168a9849e15660feae286e024@ubuntu.com>

hallyn/lxd,lxc/lxd,stgraber/lxd,lxc/lxd,stgraber/lxd,hallyn/lxd,stgraber/lxd,lxc/lxd,hallyn/lxd,lxc/lxd,lxc/lxd,hallyn/lxd,stgraber/lxd,lxc/lxd,stgraber/lxd,hallyn/lxd,lxc/lxd,hallyn/lxd,stgraber/lxd,stgraber/lxd