Added locking around mama_open() and mama_close()
Added locking around mama_open() and mama_close()

Improved the reference counting logic and added locking around mama_open() and
mama_close(). The change ensures that all initialization (one-time) and cleanup
only occurs once. It also ensures that the reference count never goes belowe
zero.

Signed-off-by: John Gray <160e368f6920b2a12076b14d9bbf683db7af0f1b@nyx.com>

dpauls/OpenMAMA,MattMulhern/OpenMamaCassandra,dmagOM/OpenMAMA-dynamic,vulcanft/openmama,jacobraj/MAMA,jacobraj/MAMA,kuangtu/OpenMAMA,MattMulhern/OpenMamaCassandra,fquinner/OpenMAMA,MattMulhern/OpenMamaCassandra,fquinner/OpenMAMA,vulcanft/openmama,philippreston/OpenMAMA,fquinner/OpenMAMA,jacobraj/MAMA,dmaguire/OpenMAMA,cloudsmith-io/openmama,dmaguire/OpenMAMA,cloudsmith-io/openmama,dmaguire/OpenMAMA,fquinner/OpenMAMA,vulcanft/openmama,dpauls/OpenMAMA,kuangtu/OpenMAMA,jacobraj/MAMA,fquinner/OpenMAMA,dmaguire/OpenMAMA,philippreston/OpenMAMA,vulcanft/openmama,cloudsmith-io/openmama,dmaguire/OpenMAMA,MattMulhern/OpenMAMA,fquinner/OpenMAMA,cloudsmith-io/openmama,philippreston/OpenMAMA,dmaguire/OpenMAMA,vulcanft/openmama,MattMulhern/OpenMAMA,cloudsmith-io/openmama,MattMulhern/OpenMamaCassandra,MattMulhern/OpenMAMA,dmagOM/OpenMAMA-dynamic,dpauls/OpenMAMA,fquinner/OpenMAMA,dmagOM/OpenMAMA-dynamic,MattMulhern/OpenMAMA,dpauls/OpenMAMA,philippreston/OpenMAMA,dpauls/OpenMAMA,dmagOM/OpenMAMA-dynamic,kuangtu/OpenMAMA,MattMulhern/OpenMAMA,dmaguire/OpenMAMA,MattMulhern/OpenMamaCassandra,MattMulhern/OpenMAMA,kuangtu/OpenMAMA,kuangtu/OpenMAMA,kuangtu/OpenMAMA,vulcanft/openmama,jacobraj/MAMA,philippreston/OpenMAMA,MattMulhern/OpenMAMA,dmagOM/OpenMAMA-dynamic,vulcanft/openmama,philippreston/OpenMAMA,MattMulhern/OpenMamaCassandra,cloudsmith-io/openmama,cloudsmith-io/openmama,philippreston/OpenMAMA,dmagOM/OpenMAMA-dynamic,jacobraj/MAMA,dpauls/OpenMAMA,kuangtu/OpenMAMA,dpauls/OpenMAMA