Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Keep io context running when stopping test system #4525

Merged

Conversation

pwojcikdev
Copy link
Contributor

@pwojcikdev pwojcikdev commented Mar 27, 2024

Ideally, asio io context would be running through the test lifetime with each component being responsible for properly canceling and joining its async operations. Getting to this point is going to take a bit more work, but this PR is a step towards this goal. It keeps io loop running when stopping nodes, which in turn allows async handlers to complete. Getting it to work required fixing a few lifetime issues and that's also a part of this PR.

Getting this merged will unblock #4523

@pwojcikdev pwojcikdev force-pushed the networking-fixes/io-context-stopping branch from 18aa5ae to 2fd368a Compare March 27, 2024 18:06
@qwahzi qwahzi added this to the V27 milestone Mar 27, 2024
clemahieu
clemahieu previously approved these changes Mar 28, 2024
@pwojcikdev pwojcikdev force-pushed the networking-fixes/io-context-stopping branch from 6479c8e to 8eb54ba Compare March 29, 2024 10:10
std::shared_ptr<nano::node> nano::test::system::make_disconnected_node (std::optional<nano::node_config> opt_node_config, nano::node_flags flags)
{
nano::node_config node_config = opt_node_config.has_value () ? *opt_node_config : default_config ();
auto node = std::make_shared<nano::node> (io_ctx, nano::unique_path (), node_config, work, flags);
if (node->init_error ())
for (auto i : initialization_blocks)
Copy link
Contributor

@dsiganos dsiganos Mar 29, 2024

Choose a reason for hiding this comment

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

make_disconnected_node() is typically used when someone wants a node without any initialisation and no network connections. the name I gave it isn't ideal, in hindsight, as it implied the node is only disconnected. It replaced code that was constructing nano::node objects without the use of system resources.

So, I think it would be best to not any additional initialisation.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out. I'll be revisiting the way nodes are added to the system with subsequent io context rework.

@pwojcikdev pwojcikdev merged commit 0b83fa6 into nanocurrency:develop Mar 30, 2024
24 of 27 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants