Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Langley <agl@google.com>2015-04-21 01:25:21 +0300
committerAdam Langley <agl@google.com>2015-05-05 03:28:22 +0300
commitab9017b0ff9da51afa3594fa41c84b7c88e1115d (patch)
treeb8ca5366c2e692a4e703231c204b9fb50fa6da43 /crypto/bio
parenta91fd063cf87b905a4d3b06387727deb4a7016d0 (diff)
Revert "bio: remove reference count."
Android uses BIO reference counting. This reverts commit 9bde6aeb76b1d2a45d76637553c3fb3f31e4ecbd. Change-Id: Ibf4a7f42477549d10829a424ea3b52f09098666c Reviewed-on: https://boringssl-review.googlesource.com/4472 Reviewed-by: David Benjamin <davidben@chromium.org> Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/bio')
-rw-r--r--crypto/bio/bio.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/bio/bio.c b/crypto/bio/bio.c
index ad6c259b..2fcad6cc 100644
--- a/crypto/bio/bio.c
+++ b/crypto/bio/bio.c
@@ -75,6 +75,7 @@ static int bio_set(BIO *bio, const BIO_METHOD *method) {
bio->method = method;
bio->shutdown = 1;
+ bio->references = 1;
if (method->create != NULL && !method->create(bio)) {
return 0;
@@ -102,6 +103,11 @@ int BIO_free(BIO *bio) {
BIO *next_bio;
for (; bio != NULL; bio = next_bio) {
+ int refs = CRYPTO_add(&bio->references, -1, CRYPTO_LOCK_BIO);
+ if (refs > 0) {
+ return 0;
+ }
+
if (bio->callback != NULL) {
int i = (int)bio->callback(bio, BIO_CB_FREE, NULL, 0, 0, 1);
if (i <= 0) {