aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstate.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Mass update of the copyright date. Honestly I don't know why I bother,lloyd2008-02-141-1/+1
| | | | | | | but might as well keep it up to date. And it's easier to do it once with a 'perl -pi' command than to update each file over time. Apologies to anyone looking at diffs.
* Remove the ability to load an external configuration file. Applicationslloyd2007-11-141-3/+0
| | | | | | | | | | | needing this functionality probably already have a preexisting configuration system that they would rather use. Also remove the documentation about this feature, and the example configuration (which was pretty out of date, anyway). RFC on this change sent to the mailing list on 11-13-2007, no responses after 24 hours. It seems quite likely this code is not in use anywhere.
* Move the self tests from LibraryInitializer::initialize tolloyd2007-10-151-0/+7
| | | | | Library_State::initialize: now the LibraryInitializer is just a simple wrapper to create/destroy the state with no other operations.
* The last checkin did not work; the Library_State constructor called code1.7.2lloyd2007-10-131-8/+28
| | | | | | | | that called global_state(), which cased an infinite recursion. Make creating a Library_State a two-phase operation, first an empty constructor (just sets all pointers to NULL), then an initializer that sets up everything needed to start up the library.
* Move most of the initializer code directly into the Library_State constructorlloyd2007-10-131-31/+43
|
* If we attempt to access the global state, and it is null, calllloyd2007-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LibraryInitializer::initialize(), which will set it for us (or fail by throwing an exception, which will be propogated to the caller). So any instances of creating a LibraryInitializer where no option arguments are passed can be removed; instead that initialization will run when or if you execute an operation where Botan requires the services provided in the state. Because no options are passed, the library will be using the default (debug and not thread safe) mutex type: so hopefully you'll quickly get an exception when the debug mutex realizes it is being used in a threaded application, but there is risk of operations silently failing before that happens. You can call LibraryInitializer::deinitialize() at the end of your main function (or whenever you think you won't need Botan anymore), to free the global state; if not a number of cleanup destructors will not run (including the final scrub of memory). You can even shut down Botan speculatively; if it turns out you need it again, it just means you'll have to take the cost of another initialization. However in applications that use Botan only in small bursts, or in rarely taken codepaths, you can remove the state entirely and suffer zero memory overhead. This probably only makes sense in memory constrained systems, but it's reasonable to do now. Speculatively deallocating the state is probably not thread safe without extra work. One thread calling deinitialize() would invalidate pointers that would have been visible to other threads. One (untested) idea: have an atomic integer with the number of current threads using Botan. If any thread decrements and hits zero, it could deinitialize Botan safely. This might cause too many repeated startup/shutdowns, which would depend on the app use pattern. In addition, since you can't pass arguments to the new Library_State, you can't specify the use of real mutexes (or anything else): so for right now, this only works in applications that are fine with the standard options. I want to find a way to get that working, though, since it's very inelegant. Currently a Default_Mutex (not at all thread safe but somewhat error checking) will be used. And self test will always be run (more on that below). I wrote a program that just initializes and shuts down in a tight loop. Running on my Gentoo box (Core2 E6400, gcc 4.1.2): thread_safe? selftest? time (ms) ------------ --------- --------- no yes 6.1 no no 3.8 yes yes 6.7 yes no 3.8 If you're actually worried that the library might start up OK but then start failing basic self tests, what you actually want to do is have a thread that runs diagnostics on your entire process state (including calling Botan's self test code) every N seconds. The question is how to get arguments from the outside world to the constructor of the Library_State that is created inside of global_state(): avoiding many self tests to save a bit of time (many applications won't care about the extra cost but sometimes 2 or 3 ms is important), and thread safety (beacuse you can't specify to use a real mutex).
* Use prefix rather than postfix increment in places where it can be used.lloyd2007-03-031-2/+2
|
* Remove a call to abort() in global_state() which was triggered if nolloyd2007-02-281-3/+0
| | | | | global state pointer was set. Presumably I put that there for debugging at some point and let it escape.
* Bump copyright year to 2007lloyd2007-01-201-1/+1
|
* Move the UI pulse functions into the global library state. That is (as bestlloyd2006-12-141-0/+20
| | | | | as I can tell) the last of the global data, with the exception of the single global_lib_state pointer in libstate.cpp
* The public add_engine API now always places the new engine at the frontlloyd2006-09-201-9/+8
| | | | | of the list. The only time when the other behavior was desired was inside the load() function, which now simply appends to the engines vector itself.
* Correctly deal with allocators added post-initialization. In particular,lloyd2006-09-111-16/+22
| | | | | | | | | | handle the case where an allocator is added that has the same name as one already registered. Flush the cached allocator pointer when the default is changed. Mark comparison operations in Pooling_Allocator::Memory_Block as inline; this seems to help the STL sort and binary search algorithms tremendously.
* Remove memory leak - the configuration object was not being deleted.lloyd2006-08-091-0/+1
|
* Make it possible to insert Engines into the front of the queue;lloyd2006-08-051-3/+7
| | | | | | otherwise any Engines added after startup (eg, application-specific ones) would only be used for new algorithm - it wouldn't be possible for them to override existing implementations.
* Remove a line that should have been deleted in the last commit.lloyd2006-07-071-1/+0
|
* Have Library_State's constructor thrown an exception if thelloyd2006-07-071-1/+2
| | | | | | | | mutex_factory argument is NULL. Have Init::initialize() pass either a new Mutex_Factory (the default no-op version), or the result of modules.mutex_factory(), depending on the value of args.thread_safe()
* Add del_fun and delete2nd functions for running deleteslloyd2006-07-021-8/+7
| | | | Use for_each + the delete wrappers in libstate.cpp
* Let modules override the transcoder object (since system libslloyd2006-07-011-0/+1
| | | | like iconv may be useful there...)
* Access the global configuration through an object reference insteadlloyd2006-07-011-51/+25
| | | | | of stand-alone functions. Store the configuration in a distinct object, rather than just a map inside the library state.
* Clean up initialization a little bit morelloyd2006-07-011-0/+23
|
* Various changes to how library initialization occurs, though I'm stilllloyd2006-06-261-1/+5
| | | | not completely happy with it.
* Support named mutexes outside of the global library state.lloyd2006-06-251-43/+29
| | | | | | Alter the AEP engine to use one in favor of a static Mutex pointer. Fix a stupid typo in an exception message.
* Guard set_timer with a check so it does not set the timer to NULLlloyd2006-06-251-2/+5
|
* Add a set_timer method to Library_State, and rearrange the orderlloyd2006-06-251-7/+14
| | | | of initialization in the constructor.
* Have allocator objects 'know' their own names, rather than keeping themlloyd2006-06-251-2/+4
| | | | around as ancillary strings.
* Make Library_State::x509_state() non-const to support lazy initialiation.lloyd2006-06-251-1/+1
|
* Have system_clock return 0, rather than crash, if no timer is setlloyd2006-06-251-7/+7
| | | | | | Initialize the X.509 global state object lazily, on first access Alter the order that global objects are deleted.
* Make set_global_state a little more elegant, by having it deletelloyd2006-06-251-2/+1
| | | | | the return value of swap_global_state rather than manipulate the state object directly.
* Add error checking to x509_state()lloyd2006-06-241-1/+5
| | | | | Initialize the X509_GlobalState pointer during Library_State construction.
* Add an X509_GlobalState pointer to the library state.lloyd2006-06-241-3/+21
| | | | Initial implementation of a factory for extension objects
* Add a swap_global_state, to allow the use of multiplelloyd2006-06-241-0/+8
| | | | simultaneous library states.
* Add some initial support for centralized/user-pluggable characterlloyd2006-06-131-0/+26
| | | | set conversions, to replace the current hardcoded stuff.
* Syntax changes to the BER and DER APIs to improve readability of codelloyd2006-05-191-0/+4
| | | | | that uses them. These changes are not backwards compatible, this commit updates all uses of the APIs within the library.
* Initial checkin1.5.6lloyd2006-05-181-0/+314