summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2018-03-07 19:07:15 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2018-03-07 19:07:15 +0000
commitdfb4682f73562f9ed38bf259543c922670070527 (patch)
tree97d279201e9366af19f2174531a5e10cda4d459b /lib
parentd594657637a7be7b7dd6d2cfe20cb6582d03d580 (diff)
backout. diff was not tested comprehensively, resulting in a broken tree.
Diffstat (limited to 'lib')
-rw-r--r--lib/libtls/man/tls_init.34
-rw-r--r--lib/libtls/tls.c32
2 files changed, 14 insertions, 22 deletions
diff --git a/lib/libtls/man/tls_init.3 b/lib/libtls/man/tls_init.3
index fe8847d0acd..5fb9cdd802f 100644
--- a/lib/libtls/man/tls_init.3
+++ b/lib/libtls/man/tls_init.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tls_init.3,v 1.8 2018/03/07 17:17:47 beck Exp $
+.\" $OpenBSD: tls_init.3,v 1.9 2018/03/07 19:07:14 deraadt Exp $
.\"
.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
.\" Copyright (c) 2016 Joel Sing <jsing@openbsd.org>
@@ -46,7 +46,7 @@ The
.Fn tls_init
function initializes global data structures.
It should be called once before any other functions.
-It may be called more than once, and may be called concurrently.
+It may be called more than once, but not concurrently.
.Pp
Before a connection is created, a configuration must be created.
The
diff --git a/lib/libtls/tls.c b/lib/libtls/tls.c
index 4a9db289bd6..c0430d7cd1d 100644
--- a/lib/libtls/tls.c
+++ b/lib/libtls/tls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tls.c,v 1.76 2018/03/07 17:17:47 beck Exp $ */
+/* $OpenBSD: tls.c,v 1.77 2018/03/07 19:07:13 deraadt Exp $ */
/*
* Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
*
@@ -19,7 +19,6 @@
#include <errno.h>
#include <limits.h>
-#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
@@ -36,35 +35,28 @@
static struct tls_config *tls_config_default;
-static int tls_init_rv = -1;
-
-static void
-tls_do_init(void)
+int
+tls_init(void)
{
+ static int tls_initialised = 0;
+
+ if (tls_initialised)
+ return (0);
+
SSL_load_error_strings();
SSL_library_init();
if (BIO_sock_init() != 1)
- return;
+ return (-1);
if ((tls_config_default = tls_config_new()) == NULL)
- return;
+ return (-1);
tls_config_default->refcount++;
- tls_init_rv = 0;
- return;
-}
-
-int
-tls_init(void)
-{
- static pthread_once_t once = PTHREAD_ONCE_INIT;
-
- if (pthread_once(&once, tls_do_init) != 0)
- return -1;
+ tls_initialised = 1;
- return tls_init_rv;
+ return (0);
}
const char *