inet6: only mark autoconf addresses tentative if detached
[dragonfly.git] / crypto / libressl / ssl / ssl_init.c
blobb521d22d07ed73d5fb4ca8801bbab0e456b35d20
1 /* $OpenBSD: ssl_init.c,v 1.2 2018/03/30 14:59:46 jsing Exp $ */
2 /*
3 * Copyright (c) 2018 Bob Beck <beck@openbsd.org>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 /* OpenSSL style init */
20 #include <pthread.h>
21 #include <stdio.h>
23 #include <openssl/objects.h>
25 #include "ssl_locl.h"
27 static pthread_t ssl_init_thread;
29 static void
30 OPENSSL_init_ssl_internal(void)
32 ssl_init_thread = pthread_self();
33 SSL_load_error_strings();
34 SSL_library_init();
37 int
38 OPENSSL_init_ssl(uint64_t opts, const void *settings)
40 static pthread_once_t once = PTHREAD_ONCE_INIT;
42 if (pthread_equal(pthread_self(), ssl_init_thread))
43 return 1; /* don't recurse */
45 OPENSSL_init_crypto(opts, settings);
47 if (pthread_once(&once, OPENSSL_init_ssl_internal) != 0)
48 return 0;
50 return 1;