Commit f989cd8c authored by Alessandro Ghedini's avatar Alessandro Ghedini Committed by Rich Salz
Browse files

Convert CRYPTO_LOCK_GET*BYNAME to new multi-threading API

parent 8f675b6e
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -55,12 +55,16 @@
#include <string.h>

#include "bio_lcl.h"
#include "internal/threads.h"

#ifndef OPENSSL_NO_SOCK
#include <openssl/err.h>
#include <openssl/buffer.h>
#include <ctype.h>

static CRYPTO_RWLOCK *bio_lookup_lock;
static CRYPTO_ONCE bio_lookup_init = CRYPTO_ONCE_STATIC_INIT;

/*
 * Throughout this file and bio_lcl.h, the existence of the macro
 * AI_PASSIVE is used to detect the availability of struct addrinfo,
@@ -623,6 +627,11 @@ static int addrinfo_wrap(int family, int socktype,
    return 1;
}

static void do_bio_lookup_init(void)
{
    bio_lookup_lock = CRYPTO_THREAD_lock_new();
}

/*-
 * BIO_lookup - look up the node and service you want to connect to.
 * @node: the node you want to connect to.
@@ -735,8 +744,9 @@ int BIO_lookup(const char *host, const char *service,
#endif
        char *proto = NULL;

        CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME);
        CRYPTO_w_lock(CRYPTO_LOCK_GETSERVBYNAME);
        CRYPTO_THREAD_run_once(&bio_lookup_init, do_bio_lookup_init);

        CRYPTO_THREAD_write_lock(bio_lookup_lock);
        he_fallback_address = INADDR_ANY;
        if (host == NULL) {
            he = &he_fallback;
@@ -838,8 +848,7 @@ int BIO_lookup(const char *host, const char *service,
            ret = 1;
        }
     err:
        CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME);
        CRYPTO_w_unlock(CRYPTO_LOCK_GETHOSTBYNAME);
        CRYPTO_THREAD_unlock(bio_lookup_lock);
    }

    return ret;
+0 −2
Original line number Diff line number Diff line
@@ -186,8 +186,6 @@ extern "C" {
# define CRYPTO_LOCK_RAND2               19
# define CRYPTO_LOCK_MALLOC              20
# define CRYPTO_LOCK_BIO                 21
# define CRYPTO_LOCK_GETHOSTBYNAME       22
# define CRYPTO_LOCK_GETSERVBYNAME       23
# define CRYPTO_LOCK_READDIR             24
# define CRYPTO_LOCK_RSA_BLINDING        25
# define CRYPTO_LOCK_DH                  26