From 2b91ffd1cee9dc87c6518b0ff8b9b675a054a6e7 Mon Sep 17 00:00:00 2001 From: alexpeshkoff Date: Thu, 28 Feb 2008 13:59:03 +0000 Subject: [PATCH] 1. Avoid suspicious operator!(). 2. Make GlobalPtr<> usable in static local variables. --- src/common/classes/init.cpp | 7 ++++++- src/common/classes/init.h | 28 ++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/common/classes/init.cpp b/src/common/classes/init.cpp index 7dc87d575f..e1b7897d05 100644 --- a/src/common/classes/init.cpp +++ b/src/common/classes/init.cpp @@ -51,6 +51,7 @@ namespace void allClean() { Firebird::InstanceControl::destructors(); + try { Firebird::StaticMutex::release(); @@ -59,7 +60,7 @@ namespace { cleanError(); } - + try { Firebird::MemoryPool::cleanup(); @@ -112,7 +113,11 @@ namespace Firebird InstanceControl::InstanceControl() { + // Initialize required subsystems, including static mutex, needed next line init(); + + // Ready to be used in static variables inside functions + MutexLockGuard guard(*mutex); next = instanceList; instanceList = this; } diff --git a/src/common/classes/init.h b/src/common/classes/init.h index 5074e7e59e..dec576fb58 100644 --- a/src/common/classes/init.h +++ b/src/common/classes/init.h @@ -32,9 +32,20 @@ namespace Firebird { +// Support for common mutex for various inits + +class StaticMutex +{ +protected: + static Mutex* mutex; +public: + static void create(); + static void release(); +}; + // InstanceControl - interface for almost all global variables -class InstanceControl +class InstanceControl : private StaticMutex { public: InstanceControl(); @@ -80,21 +91,6 @@ public: { return instance; } - bool operator!() const throw() - { - return instance ? false : true; - } -}; - -// Support for common mutex for various inits - -class StaticMutex -{ -protected: - static Mutex* mutex; -public: - static void create(); - static void release(); }; // InitMutex - executes static void C::init() once and only once