Front-ported Nickolay's improvement for the shared counter.

git-svn-id: svn+ssh://svn.code.sf.net/p/firebird/code/firebird/trunk@59966 65644016-39b1-43b1-bf79-96bc8fe82c15
Better (methinks) synchronization for the monitoring stuff. Being field tested.

git-svn-id: svn+ssh://svn.code.sf.net/p/firebird/code/firebird/trunk@59967 65644016-39b1-43b1-bf79-96bc8fe82c15