Convert reference counts in ssl/
Convert reference counts in ssl/ to use |CRYPTO_refcount_t|. Change-Id: I5d60f641b0c89b1ddfe38bfbd9d7285c60377f4c Reviewed-on: https://boringssl-review.googlesource.com/4773 Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
0da323a8b8
commit
0b5e3908cf
@ -150,15 +150,13 @@
|
|||||||
#include <openssl/hmac.h>
|
#include <openssl/hmac.h>
|
||||||
#include <openssl/lhash.h>
|
#include <openssl/lhash.h>
|
||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
|
#include <openssl/thread.h>
|
||||||
#include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
|
|
||||||
#if !defined(OPENSSL_WINDOWS)
|
#if !defined(OPENSSL_WINDOWS)
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Some code expected to get the threading functions by including ssl.h. */
|
|
||||||
#include <openssl/thread.h>
|
|
||||||
|
|
||||||
/* wpa_supplicant expects to get the version functions from ssl.h */
|
/* wpa_supplicant expects to get the version functions from ssl.h */
|
||||||
#include <openssl/crypto.h>
|
#include <openssl/crypto.h>
|
||||||
|
|
||||||
@ -414,7 +412,7 @@ struct ssl_session_st {
|
|||||||
* not ok, we must remember the error for session reuse: */
|
* not ok, we must remember the error for session reuse: */
|
||||||
long verify_result; /* only for servers */
|
long verify_result; /* only for servers */
|
||||||
|
|
||||||
int references;
|
CRYPTO_refcount_t references;
|
||||||
long timeout;
|
long timeout;
|
||||||
long time;
|
long time;
|
||||||
|
|
||||||
@ -849,7 +847,7 @@ struct ssl_ctx_st {
|
|||||||
SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, uint8_t *data, int len,
|
SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, uint8_t *data, int len,
|
||||||
int *copy);
|
int *copy);
|
||||||
|
|
||||||
int references;
|
CRYPTO_refcount_t references;
|
||||||
|
|
||||||
/* if defined, these override the X509_verify_cert() calls */
|
/* if defined, these override the X509_verify_cert() calls */
|
||||||
int (*app_verify_callback)(X509_STORE_CTX *, void *);
|
int (*app_verify_callback)(X509_STORE_CTX *, void *);
|
||||||
|
@ -293,10 +293,10 @@ SSL *SSL_new(SSL_CTX *ctx) {
|
|||||||
s->quiet_shutdown = ctx->quiet_shutdown;
|
s->quiet_shutdown = ctx->quiet_shutdown;
|
||||||
s->max_send_fragment = ctx->max_send_fragment;
|
s->max_send_fragment = ctx->max_send_fragment;
|
||||||
|
|
||||||
CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);
|
CRYPTO_refcount_inc(&ctx->references);
|
||||||
s->ctx = ctx;
|
s->ctx = ctx;
|
||||||
s->tlsext_ticket_expected = 0;
|
s->tlsext_ticket_expected = 0;
|
||||||
CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);
|
CRYPTO_refcount_inc(&ctx->references);
|
||||||
s->initial_ctx = ctx;
|
s->initial_ctx = ctx;
|
||||||
if (ctx->tlsext_ecpointformatlist) {
|
if (ctx->tlsext_ecpointformatlist) {
|
||||||
s->tlsext_ecpointformatlist = BUF_memdup(
|
s->tlsext_ecpointformatlist = BUF_memdup(
|
||||||
@ -1758,7 +1758,7 @@ err2:
|
|||||||
|
|
||||||
void SSL_CTX_free(SSL_CTX *ctx) {
|
void SSL_CTX_free(SSL_CTX *ctx) {
|
||||||
if (ctx == NULL ||
|
if (ctx == NULL ||
|
||||||
CRYPTO_add(&ctx->references, -1, CRYPTO_LOCK_SSL_CTX) > 0) {
|
!CRYPTO_refcount_dec_and_test_zero(&ctx->references)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2320,7 +2320,7 @@ SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx) {
|
|||||||
ssl_cert_free(ssl->cert);
|
ssl_cert_free(ssl->cert);
|
||||||
ssl->cert = ssl_cert_dup(ctx->cert);
|
ssl->cert = ssl_cert_dup(ctx->cert);
|
||||||
|
|
||||||
CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX);
|
CRYPTO_refcount_inc(&ctx->references);
|
||||||
SSL_CTX_free(ssl->ctx); /* decrement reference count */
|
SSL_CTX_free(ssl->ctx); /* decrement reference count */
|
||||||
ssl->ctx = ctx;
|
ssl->ctx = ctx;
|
||||||
|
|
||||||
|
@ -607,14 +607,14 @@ static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lock) {
|
|||||||
|
|
||||||
SSL_SESSION *SSL_SESSION_up_ref(SSL_SESSION *session) {
|
SSL_SESSION *SSL_SESSION_up_ref(SSL_SESSION *session) {
|
||||||
if (session) {
|
if (session) {
|
||||||
CRYPTO_add(&session->references, 1, CRYPTO_LOCK_SSL_SESSION);
|
CRYPTO_refcount_inc(&session->references);
|
||||||
}
|
}
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSL_SESSION_free(SSL_SESSION *session) {
|
void SSL_SESSION_free(SSL_SESSION *session) {
|
||||||
if (session == NULL ||
|
if (session == NULL ||
|
||||||
CRYPTO_add(&session->references, -1, CRYPTO_LOCK_SSL_SESSION) > 0) {
|
!CRYPTO_refcount_dec_and_test_zero(&session->references)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user