/*
* Initialise the interpreter, registering operations.
*/
- if (unlang_init_global() < 0) return -1;
+ if (unlang_init_global() < 0) EXIT_WITH_FAILURE;
if (server_init(config->root_cs) < 0) EXIT_WITH_FAILURE;
*/
if (dl_modules) talloc_free(dl_modules);
-#ifdef HAVE_OPENSSL_CRYPTO_H
- /*
- * Make sure we clean up the TLS dictionary...
- */
- fr_tls_dict_free();
-#endif
-
/*
* Cleanup everything else
*/
#include <freeradius-devel/util/debug.h>
static uint32_t instance_count = 0;
-static uint32_t dict_ref_count = 0;
/** The context which holds any memory OpenSSL allocates
*
TALLOC_FREE(global_mutexes);
- fr_tls_dict_free();
+ fr_dict_autofree(tls_dict);
}
#else
/** Free any memory alloced by libssl
OPENSSL_cleanup();
- fr_tls_dict_free();
+ fr_dict_autofree(tls_dict);
}
#endif
/** Load dictionary attributes
*
+ * This is a separate function because of ordering issues.
+ * OpenSSL may need to be initialised before anything else
+ * including the dictionary loader.
+ *
+ * fr_openssl_free will unload both the dictionary and the
+ * OpenSSL library.
*/
int fr_tls_dict_init(void)
{
- /*
- * Needs to be tracked separately in case
- * this is called before the TLS library
- * is initialised.
- *
- * fr_dict_autofree will only decrement the
- * dict ref count once.
- */
- if (dict_ref_count > 0) {
- dict_ref_count++;
- return 0;
- }
-
if (fr_dict_autoload(tls_dict) < 0) {
PERROR("Failed initialising protocol library");
fr_openssl_free();
fr_openssl_free();
return -1;
}
-
- dict_ref_count++;
-
return 0;
}
-
-void fr_tls_dict_free(void)
-{
- if (--dict_ref_count > 0) return;
-
- fr_dict_autofree(tls_dict);
-}
#endif /* WITH_TLS */