Skip to content

Conversation

@tjps
Copy link
Contributor

@tjps tjps commented Mar 22, 2017

The set of objects used in the OpenSSL locking callback do not need to be allocated using the OpenSSL allocator.

@fanquake
Copy link
Member

Please be aware the we use the [trivial] label for changes that are essentially non-code changes. i.e fixing typos. This PR would not be considered trivial.

@fanquake fanquake changed the title [trivial] No need to use OpenSSL malloc/free No need to use OpenSSL malloc/free Mar 22, 2017
@tjps
Copy link
Contributor Author

tjps commented Mar 22, 2017

Ack. will remove the trivial marker when I update the PR for the apparently broken test.

src/util.cpp Outdated
Copy link
Contributor

@jonasschnelli jonasschnelli Mar 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK it was slightly wrong to free the ppmutexOpenSSL via OPENSSL_free. IMO only objects alloced by OPENSSL_malloc() should use OPENSSL_free(). This change makes sense.
I was wrong: It is currently (master) alloced with OPENSSL_malloc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is allocated via OPENSSL_malloc

ppmutexOpenSSL = (CCriticalSection**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(CCriticalSection*));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is allocated via OPENSSL_malloc

Oh. Right.. it was. Nervermind then.

@jonasschnelli
Copy link
Contributor

utACK 0765b6c9f08c5bac848ba8ac7c03471513fa4654

@tjps
Copy link
Contributor Author

tjps commented Mar 28, 2017

Bump, for one less OpenSSL eyesore

src/util.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably cleaner to just use a std::unique_ptr<CCriticalSection[]>

src/util.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and then here ppmutexOpenSSL.reset(new CCriticalSection[CRYPTO_num_locks()]); I think is correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. I always like shaving lines off.

@sipa
Copy link
Member

sipa commented Mar 29, 2017

utACK 6d5dd60

@laanwj laanwj merged commit 6d5dd60 into bitcoin:master Apr 3, 2017
laanwj added a commit that referenced this pull request Apr 3, 2017
6d5dd60 No need to use OpenSSL malloc/free (Thomas Snider)

Tree-SHA512: 29f790067ffd5a10a8e1a621318a0ba445691f57c804aa3b7c8ca372c8408d8c7fe703c42b48018e400fc32e3feff5ab401d97433910ce2c50e69da0b8a6662e
@tjps tjps deleted the tjps_ssl_mutex branch May 1, 2017 20:19
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 20, 2019
6d5dd60 No need to use OpenSSL malloc/free (Thomas Snider)

Tree-SHA512: 29f790067ffd5a10a8e1a621318a0ba445691f57c804aa3b7c8ca372c8408d8c7fe703c42b48018e400fc32e3feff5ab401d97433910ce2c50e69da0b8a6662e
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants