diff options
author | lloyd <[email protected]> | 2008-04-02 18:52:13 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-04-02 18:52:13 +0000 |
commit | 8a5ffc5c6294786ad70f7a8fdd7606f411690ce9 (patch) | |
tree | 16b7d8d757e1ac6c8b2460d3e6a42768de466c8c /include | |
parent | 91c318bbad1fcff1c9b04f1077fb4ec75d59a549 (diff) |
Remove the Named_Mutex_Holder and associated code. Convert all uses to
instead allocate a reference to a mutex locally and use the more typical
Mutex_Holder RAII object.
Named_Mutex_Holder (and in particular the string->mutex mappings contained
in the global state) have been found to be pretty expensive in at least
some situations (see post by Jack Cummings to monotone-devel 2008-03-12),
and doesn't really buy us that much in terms of ease of use. Also, it
relies on the global state object, which has shown itself to be a rich
source of race conditions and locking bugs. The intent is to incrementally
remove all of the shared / global state and require applications to maintain
that state where necessary.
Diffstat (limited to 'include')
-rw-r--r-- | include/config.h | 9 | ||||
-rw-r--r-- | include/libstate.h | 6 | ||||
-rw-r--r-- | include/mutex.h | 12 |
3 files changed, 12 insertions, 15 deletions
diff --git a/include/config.h b/include/config.h index 5e3f8ed1c..ad6eafcac 100644 --- a/include/config.h +++ b/include/config.h @@ -6,7 +6,7 @@ #ifndef BOTAN_POLICY_CONF_H__ #define BOTAN_POLICY_CONF_H__ -#include <botan/types.h> +#include <botan/mutex.h> #include <botan/enums.h> #include <string> #include <vector> @@ -20,6 +20,9 @@ namespace Botan { class Config { public: + Config(); + ~Config(); + void load_defaults(); std::string get(const std::string&, const std::string&) const; @@ -43,7 +46,11 @@ class Config static void choose_sig_format(const std::string&, std::string&, Signature_Format&); private: + Config(const Config&) {} + Config& operator=(const Config&) { return (*this); } + std::map<std::string, std::string> settings; + Mutex* mutex; }; /************************************************* diff --git a/include/libstate.h b/include/libstate.h index 666677ff3..297e39479 100644 --- a/include/libstate.h +++ b/include/libstate.h @@ -68,7 +68,6 @@ class Library_State class Config& config() const; class Mutex* get_mutex() const; - class Mutex* get_named_mutex(const std::string&); void set_x509_state(class X509_GlobalState*); class X509_GlobalState& x509_state(); @@ -86,11 +85,14 @@ class Library_State class Engine* get_engine_n(u32bit) const; class Mutex_Factory* mutex_factory; + class Mutex* allocator_lock; + class Mutex* engine_lock; + class Mutex* rng_lock; + class Timer* timer; mutable class Config* config_obj; class X509_GlobalState* x509_state_obj; - std::map<std::string, class Mutex*> locks; std::map<std::string, Allocator*> alloc_factory; mutable Allocator* cached_default_allocator; diff --git a/include/mutex.h b/include/mutex.h index ef45a7dce..9f750e526 100644 --- a/include/mutex.h +++ b/include/mutex.h @@ -52,18 +52,6 @@ class Mutex_Holder Mutex* mux; }; -/************************************************* -* Named Mutex Holder * -*************************************************/ -class Named_Mutex_Holder - { - public: - Named_Mutex_Holder(const std::string&); - ~Named_Mutex_Holder(); - private: - const std::string mutex_name; - }; - } #endif |