mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 14:03:07 +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;
|
// was: const static ConfigImpl sysConfig;
|
||||||
|
|
||||||
|
static ConfigImpl *sys_config = NULL;
|
||||||
|
#ifdef MULTI_THREAD
|
||||||
|
static Firebird::Spinlock config_init_lock;
|
||||||
|
#endif
|
||||||
|
|
||||||
const ConfigImpl& ConfigImpl::instance()
|
const ConfigImpl& ConfigImpl::instance()
|
||||||
{
|
{
|
||||||
static ConfigImpl *config = 0;
|
if (!sys_config) {
|
||||||
if (!config) {
|
#ifdef MULTI_THREAD
|
||||||
config = FB_NEW(*getDefaultMemoryPool()) ConfigImpl;
|
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()
|
#define sysConfig ConfigImpl::instance()
|
||||||
|
Loading…
Reference in New Issue
Block a user