diff options
author | bcook <> | 2018-11-11 06:41:28 +0000 |
---|---|---|
committer | bcook <> | 2018-11-11 06:41:28 +0000 |
commit | c3082ab78ba758ef51c552b6a91bdf1236de0cf8 (patch) | |
tree | 6d18ff101148258c403e820ff423d10a65fba89e /src/regress/lib/libssl/ssl/ssltest.c | |
parent | 32ccc9aa9f3dd1c0efa02d4b21376521a91e4705 (diff) | |
download | openbsd-c3082ab78ba758ef51c552b6a91bdf1236de0cf8.tar.gz openbsd-c3082ab78ba758ef51c552b6a91bdf1236de0cf8.tar.bz2 openbsd-c3082ab78ba758ef51c552b6a91bdf1236de0cf8.zip |
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@
Diffstat (limited to 'src/regress/lib/libssl/ssl/ssltest.c')
-rw-r--r-- | src/regress/lib/libssl/ssl/ssltest.c | 56 |
1 files changed, 0 insertions, 56 deletions
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) | |||
403 | BIO_printf(bio_stdout, "\n"); | 403 | BIO_printf(bio_stdout, "\n"); |
404 | } | 404 | } |
405 | 405 | ||
406 | static void | ||
407 | lock_dbg_cb(int mode, int type, const char *file, int line) | ||
408 | { | ||
409 | static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */ | ||
410 | const char *errstr = NULL; | ||
411 | int rw; | ||
412 | |||
413 | rw = mode & (CRYPTO_READ|CRYPTO_WRITE); | ||
414 | if (!((rw == CRYPTO_READ) || (rw == CRYPTO_WRITE))) { | ||
415 | errstr = "invalid mode"; | ||
416 | goto err; | ||
417 | } | ||
418 | |||
419 | if (type < 0 || type >= CRYPTO_NUM_LOCKS) { | ||
420 | errstr = "type out of bounds"; | ||
421 | goto err; | ||
422 | } | ||
423 | |||
424 | if (mode & CRYPTO_LOCK) { | ||
425 | if (modes[type]) { | ||
426 | errstr = "already locked"; | ||
427 | /* must not happen in a single-threaded program | ||
428 | * (would deadlock) */ | ||
429 | goto err; | ||
430 | } | ||
431 | |||
432 | modes[type] = rw; | ||
433 | } else if (mode & CRYPTO_UNLOCK) { | ||
434 | if (!modes[type]) { | ||
435 | errstr = "not locked"; | ||
436 | goto err; | ||
437 | } | ||
438 | |||
439 | if (modes[type] != rw) { | ||
440 | errstr = (rw == CRYPTO_READ) ? | ||
441 | "CRYPTO_r_unlock on write lock" : | ||
442 | "CRYPTO_w_unlock on read lock"; | ||
443 | } | ||
444 | |||
445 | modes[type] = 0; | ||
446 | } else { | ||
447 | errstr = "invalid mode"; | ||
448 | goto err; | ||
449 | } | ||
450 | |||
451 | err: | ||
452 | if (errstr) { | ||
453 | /* we cannot use bio_err here */ | ||
454 | fprintf(stderr, | ||
455 | "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n", | ||
456 | errstr, mode, type, file, line); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | int | 406 | int |
461 | main(int argc, char *argv[]) | 407 | main(int argc, char *argv[]) |
462 | { | 408 | { |
@@ -495,8 +441,6 @@ main(int argc, char *argv[]) | |||
495 | 441 | ||
496 | bio_err = BIO_new_fp(stderr, BIO_NOCLOSE|BIO_FP_TEXT); | 442 | bio_err = BIO_new_fp(stderr, BIO_NOCLOSE|BIO_FP_TEXT); |
497 | 443 | ||
498 | CRYPTO_set_locking_callback(lock_dbg_cb); | ||
499 | |||
500 | bio_stdout = BIO_new_fp(stdout, BIO_NOCLOSE|BIO_FP_TEXT); | 444 | bio_stdout = BIO_new_fp(stdout, BIO_NOCLOSE|BIO_FP_TEXT); |
501 | 445 | ||
502 | argc--; | 446 | argc--; |