mainloop: fix reload handling

The mainloop refactor broke reload as one of the conditionals were negated
in its meaning, causing the reload machinery to never actually start.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
stats: added locking around GHashTable
stats: fix a stats-counter reference counting problem

Associated counters did not properly count the number of outstanding
references causing dynamic stats counters (e.g. per-$PROGRAM,
$HOST and $HOST_FROM) to be miscounted.

This didn't cause memory corruption as this reference counter didn't drive
free operations, it only validated validating stats
registrations/unregistratiions, but wasn't nice nevertheless.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>