2 * Copyright (c) 2018 Bob Beck <beck@openbsd.org>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 /* OpenSSL style init */
22 #include <openssl/objects.h>
26 static pthread_t ssl_init_thread
;
29 OPENSSL_init_ssl_internal(void)
31 ssl_init_thread
= pthread_self();
32 SSL_load_error_strings();
37 OPENSSL_init_ssl(uint64_t opts
, const void *settings
)
39 static pthread_once_t once
= PTHREAD_ONCE_INIT
;
41 if (pthread_equal(pthread_self(), ssl_init_thread
))
42 return 1; /* don't recurse */
44 OPENSSL_init_crypto(opts
, settings
);
46 if (pthread_once(&once
, OPENSSL_init_ssl_internal
) != 0)