mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 07:23:04 +01:00
Fix another initializatoin race condition
This commit is contained in:
parent
ea6e34312b
commit
7558470e08
@ -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
|
||||
}
|
||||
return *config;
|
||||
} catch(const std::exception&) {
|
||||
config_init_lock.leave();
|
||||
throw;
|
||||
}
|
||||
config_init_lock.leave();
|
||||
#endif
|
||||
}
|
||||
return *sys_config;
|
||||
}
|
||||
|
||||
#define sysConfig ConfigImpl::instance()
|
||||
|
Loading…
Reference in New Issue
Block a user