8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 04:43:03 +01:00

Fix another initializatoin race condition

This commit is contained in:
skidder 2003-12-14 04:34:37 +00:00
parent ea6e34312b
commit 7558470e08

View File

@ -115,13 +115,30 @@ const ConfigImpl::ConfigEntry ConfigImpl::entries[] =
// was: const static ConfigImpl sysConfig;
static ConfigImpl *sys_config = NULL;
#ifdef MULTI_THREAD
static Firebird::Spinlock config_init_lock;
#endif
const ConfigImpl& ConfigImpl::instance()
{
static ConfigImpl *config = 0;
if (!config) {
config = FB_NEW(*getDefaultMemoryPool()) ConfigImpl;
if (!sys_config) {
#ifdef MULTI_THREAD
try {
config_init_lock.enter();
if (!sys_config) {
#endif
sys_config = FB_NEW(*getDefaultMemoryPool()) ConfigImpl;
#ifdef MULTI_THREAD
}
} catch(const std::exception&) {
config_init_lock.leave();
throw;
}
config_init_lock.leave();
#endif
}
return *config;
return *sys_config;
}
#define sysConfig ConfigImpl::instance()