diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/init_def.cpp | 4 | ||||
-rw-r--r-- | src/libstate.cpp | 36 |
2 files changed, 31 insertions, 9 deletions
diff --git a/src/init_def.cpp b/src/init_def.cpp index 50365b3d6..abfbe646e 100644 --- a/src/init_def.cpp +++ b/src/init_def.cpp @@ -18,7 +18,9 @@ void LibraryInitializer::initialize(const InitializerOptions& args, { try { - set_global_state(new Library_State(args, modules)); + set_global_state(new Library_State); + + global_state().initialize(args, modules); if(args.fips_mode() || args.self_test()) { diff --git a/src/libstate.cpp b/src/libstate.cpp index 8d6475e64..04a5760cb 100644 --- a/src/libstate.cpp +++ b/src/libstate.cpp @@ -311,7 +311,6 @@ Config& Library_State::config() const { if(!config_obj) { - printf("Lazy creation of the global config\n"); config_obj = new Config(); config_obj->load_defaults(); } @@ -320,16 +319,23 @@ Config& Library_State::config() const } /************************************************* -* Library_State Constructor * +* Load a set of modules * *************************************************/ -Library_State::Library_State(const InitializerOptions& args, - Modules& modules) +void Library_State::initialize(const InitializerOptions& args, + Modules& modules) { + if(mutex_factory) + throw Invalid_State("Library_State has already been initialized"); + if(args.thread_safe()) mutex_factory = modules.mutex_factory(); else mutex_factory = new Default_Mutex_Factory; + cached_default_allocator = 0; + x509_state_obj = 0; + ui = 0; + timer = modules.timer(); transcoder = modules.transcoder(); @@ -340,10 +346,6 @@ Library_State::Library_State(const InitializerOptions& args, locks["allocator"] = get_mutex(); locks["rng"] = get_mutex(); locks["engine"] = get_mutex(); - rng = 0; - cached_default_allocator = 0; - x509_state_obj = 0; - ui = 0; std::vector<Allocator*> mod_allocs = modules.allocators(); for(u32bit j = 0; j != mod_allocs.size(); ++j) @@ -379,6 +381,24 @@ Library_State::Library_State(const InitializerOptions& args, } /************************************************* +* Library_State Constructor * +*************************************************/ +Library_State::Library_State() + { + mutex_factory = 0; + + timer = 0; + config_obj = 0; + x509_state_obj = 0; + + ui = 0; + transcoder = 0; + rng = 0; + cached_default_allocator = 0; + ui = 0; + } + +/************************************************* * Library_State Destructor * *************************************************/ Library_State::~Library_State() |