summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2015-03-18 10:34:47 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2015-03-18 10:34:47 +0100
commit205ad24f4a7226c8cf14715fbf7c77e931f1616b (patch)
tree1084ec990a81cced5275e0a04527a6dcc9d674d7
parent3862a97af5ebefa656aa738af37f443ad86f8a3e (diff)
downloadgnutls-205ad24f4a7226c8cf14715fbf7c77e931f1616b.tar.gz
Added environment variable which can override automatic global initialization
-rw-r--r--lib/gnutls_global.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/gnutls_global.c b/lib/gnutls_global.c
index 27e1c56f41..cb7448af64 100644
--- a/lib/gnutls_global.c
+++ b/lib/gnutls_global.c
@@ -189,9 +189,10 @@ static int _gnutls_init_ret = 0;
* function can be called many times, but will only do something the
* first time.
*
- * Since GnuTLS 3.3.0 this function is only required in systems that
- * do not support library constructors and static linking. This
- * function also became thread safe.
+ * Since GnuTLS 3.3.0 this function is automatically called on library
+ * constructor. Since the same version this function is also thread safe.
+ * The automatic initialization can be avoided if the environment variable
+ * %GNUTLS_NO_EXPLICIT_INIT is set to be 1.
*
* A subsequent call of this function if the initial has failed will
* return the same error code.
@@ -446,6 +447,14 @@ const char *gnutls_check_version(const char *req_version)
static void _CONSTRUCTOR lib_init(void)
{
int ret;
+const char *e;
+
+ e = getenv("GNUTLS_NO_EXPLICIT_INIT");
+ if (e != NULL) {
+ ret = atoi(e);
+ if (ret == 1)
+ return;
+ }
ret = gnutls_global_init();
if (ret < 0) {
@@ -456,5 +465,14 @@ int ret;
static void _DESTRUCTOR lib_deinit(void)
{
+ const char *e;
+
+ e = getenv("GNUTLS_NO_EXPLICIT_INIT");
+ if (e != NULL) {
+ int ret = atoi(e);
+ if (ret == 1)
+ return;
+ }
+
_gnutls_global_deinit(1);
}