From c3082ab78ba758ef51c552b6a91bdf1236de0cf8 Mon Sep 17 00:00:00 2001 From: bcook <> Date: Sun, 11 Nov 2018 06:41:28 +0000 Subject: Add automatic threading initialization for libcrypto. This implements automatic thread support initialization in libcrypto. This does not remove any functions from the ABI, but does turn them into no-ops. Stub implementations of pthread_mutex_(init|lock|unlock) are provided for ramdisks. This does not implement the new OpenSSL 1.1 thread API internally, keeping the original CRYTPO_lock / CRYPTO_add_lock functions for library locking. For -portable, crypto_lock.c can be reimplemented with OS-specific primitives as needed. ok beck@, tb@, looks sane guenther@ --- src/regress/lib/libssl/ssl/ssltest.c | 56 ------------------------------------ 1 file changed, 56 deletions(-) (limited to 'src/regress/lib/libssl/ssl/ssltest.c') diff --git a/src/regress/lib/libssl/ssl/ssltest.c b/src/regress/lib/libssl/ssl/ssltest.c index 7137d0c407..4460b1bc37 100644 --- a/src/regress/lib/libssl/ssl/ssltest.c +++ b/src/regress/lib/libssl/ssl/ssltest.c @@ -403,60 +403,6 @@ print_details(SSL *c_ssl, const char *prefix) BIO_printf(bio_stdout, "\n"); } -static void -lock_dbg_cb(int mode, int type, const char *file, int line) -{ - static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */ - const char *errstr = NULL; - int rw; - - rw = mode & (CRYPTO_READ|CRYPTO_WRITE); - if (!((rw == CRYPTO_READ) || (rw == CRYPTO_WRITE))) { - errstr = "invalid mode"; - goto err; - } - - if (type < 0 || type >= CRYPTO_NUM_LOCKS) { - errstr = "type out of bounds"; - goto err; - } - - if (mode & CRYPTO_LOCK) { - if (modes[type]) { - errstr = "already locked"; - /* must not happen in a single-threaded program - * (would deadlock) */ - goto err; - } - - modes[type] = rw; - } else if (mode & CRYPTO_UNLOCK) { - if (!modes[type]) { - errstr = "not locked"; - goto err; - } - - if (modes[type] != rw) { - errstr = (rw == CRYPTO_READ) ? - "CRYPTO_r_unlock on write lock" : - "CRYPTO_w_unlock on read lock"; - } - - modes[type] = 0; - } else { - errstr = "invalid mode"; - goto err; - } - -err: - if (errstr) { - /* we cannot use bio_err here */ - fprintf(stderr, - "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n", - errstr, mode, type, file, line); - } -} - int main(int argc, char *argv[]) { @@ -495,8 +441,6 @@ main(int argc, char *argv[]) bio_err = BIO_new_fp(stderr, BIO_NOCLOSE|BIO_FP_TEXT); - CRYPTO_set_locking_callback(lock_dbg_cb); - bio_stdout = BIO_new_fp(stdout, BIO_NOCLOSE|BIO_FP_TEXT); argc--; -- cgit v1.2.3-55-g6feb