Use a convenient global instead of passing use_memory_pools explicitly #2059
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Originally it was discussed whether a global would be more beneficial if these pools were going to be used in more areas, globals are generally frowned upon given initialization issues etc.. it was decided that it would be riskier given we are close to a release. However @cryptocode found passing it as a parameter was not much safer. The
nano::confirm_ack
constructor has a newbool
parameter, the prototype is now:confirm_ack (bool &, nano::stream &, nano::message_header const &, bool, nano::vote_uniquer * = nullptr);
The function
nano::message_parser::deserialize_confirm_ack
declares the following:nano::confirm_ack incoming (error, stream_a, header_a, &vote_uniquer);
This was mistakenly not modified. The
&vote_uniquer
is implicitly cast to the newbool
parameter, sovote_uniquer
is alwaysnullptr
here. Compiler errors didn't help here, and it probably shows we need a test for thevote_uniquer
used here as well.It seems a global would actually be safer as we make heavy use of default parameters. It doesn't need to be protected by a
mutex
luckily as we set the variable during initialization before it is used and we don't currently use it in any other global variables, I've done an ASAN run with the daemon on Mac/Clang a few times and it didn't find any issues.For testing purposes, I've left the
core_test
using memory pool,rpc_test
isn't, and theload_test
uses 50% of both.