summaryrefslogtreecommitdiff
path: root/lib/locks.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2014-05-07 07:24:03 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2014-05-07 07:24:03 +0200
commit61e341b2ac7ac4447d4600603c76a7d2d16ccfc7 (patch)
tree3ab0e075a6020e8a8a994613991675eea03f0c47 /lib/locks.c
parent8a0bbdd4f1f4f928f6f8390439b606287360143f (diff)
downloadgnutls-61e341b2ac7ac4447d4600603c76a7d2d16ccfc7.tar.gz
re-enabled gnutls_global_set_mutex().
Diffstat (limited to 'lib/locks.c')
-rw-r--r--lib/locks.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/locks.c b/lib/locks.c
index a5f16e9e88..e2acc79618 100644
--- a/lib/locks.c
+++ b/lib/locks.c
@@ -39,23 +39,32 @@
* With this function you are allowed to override the default mutex
* locks used in some parts of gnutls and dependent libraries. This function
* should be used if you have complete control of your program and libraries.
- * Do not call this function from a library. Instead only initialize gnutls and
- * the default OS mutex locks will be used.
- *
- * This function must be called before gnutls_global_init().
+ * Do not call this function from a library, or preferrably from any application
+ * unless really needed to. GnuTLS will use the appropriate locks for the running
+ * system.
*
+ * This function must be called prior to any other gnutls function.
+ *
* Since: 2.12.0
**/
void
gnutls_global_set_mutex(mutex_init_func init, mutex_deinit_func deinit,
mutex_lock_func lock, mutex_unlock_func unlock)
{
+int ret;
+
if (init == NULL || deinit == NULL || lock == NULL
|| unlock == NULL)
return;
+ gnutls_global_deinit();
+
gnutls_mutex_init = init;
gnutls_mutex_deinit = deinit;
gnutls_mutex_lock = lock;
gnutls_mutex_unlock = unlock;
+
+ ret = gnutls_global_init();
+ if (ret < 0)
+ _gnutls_debug_log("error in gnutls_global_init(): %s\n", gnutls_strerror(ret));
}