mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-28 10:46:22 +00:00
Introduce our own shutdown callback mechanism.
Instead of adding stuff to `_shutdown()`, we can now register a shutdown routine from the respective `init()` function of our modules. This also has the advantage, that we're sure they're called in reverse order from how the initialization happened. I didn't simply use `atexit()` because POSIX says that the number of possible callbacks is limited (min 32) and I was not sure whether we will maybe extend this number at one point. Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
@@ -56,10 +56,25 @@ static Autocomplete certs_ac;
|
||||
|
||||
static char* current_fp;
|
||||
|
||||
static void
|
||||
_tlscerts_close(void)
|
||||
{
|
||||
free_keyfile(&tlscerts_prof_keyfile);
|
||||
tlscerts = NULL;
|
||||
|
||||
free(current_fp);
|
||||
current_fp = NULL;
|
||||
|
||||
autocomplete_free(certs_ac);
|
||||
}
|
||||
|
||||
void
|
||||
tlscerts_init(void)
|
||||
{
|
||||
log_info("Loading TLS certificates");
|
||||
|
||||
prof_add_shutdown_routine(_tlscerts_close);
|
||||
|
||||
load_data_keyfile(&tlscerts_prof_keyfile, FILE_TLSCERTS);
|
||||
tlscerts = tlscerts_prof_keyfile.keyfile;
|
||||
|
||||
@@ -356,18 +371,6 @@ tlscerts_free(TLSCertificate* cert)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tlscerts_close(void)
|
||||
{
|
||||
free_keyfile(&tlscerts_prof_keyfile);
|
||||
tlscerts = NULL;
|
||||
|
||||
free(current_fp);
|
||||
current_fp = NULL;
|
||||
|
||||
autocomplete_free(certs_ac);
|
||||
}
|
||||
|
||||
static void
|
||||
_save_tlscerts(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user