Add SSL_CTX_up_ref. Upstream added this in a18a31e49d266. The various *_up_ref functions return a variety of types, but this one returns int because upstream appears to be trying to unify around that. (See upstream's c5ebfcab713.) Change-Id: I7e1cfe78c3a32f5a85b1b3c14428bd91548aba6d Reviewed-on: https://boringssl-review.googlesource.com/8581 Reviewed-by: Adam Langley <alangley@gmail.com>
diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h index 627c288..3bbdb17 100644 --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h
@@ -194,6 +194,9 @@ * on error. */ OPENSSL_EXPORT SSL_CTX *SSL_CTX_new(const SSL_METHOD *method); +/* SSL_CTX_up_ref increments the reference count of |ctx|. It returns one. */ +OPENSSL_EXPORT int SSL_CTX_up_ref(SSL_CTX *ctx); + /* SSL_CTX_free releases memory associated with |ctx|. */ OPENSSL_EXPORT void SSL_CTX_free(SSL_CTX *ctx);
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 21e5207..534480a 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c
@@ -314,6 +314,11 @@ return NULL; } +int SSL_CTX_up_ref(SSL_CTX *ctx) { + CRYPTO_refcount_inc(&ctx->references); + return 1; +} + void SSL_CTX_free(SSL_CTX *ctx) { if (ctx == NULL || !CRYPTO_refcount_dec_and_test_zero(&ctx->references)) {