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

Networking cleanup continued #4495

Merged

Conversation

pwojcikdev
Copy link
Contributor

This PR focuses on cleanup of tcp_channels class. It eliminates some obvious inefficiencies (the update function), offloads peer reachout loop to a dedicated thread and fixes shutdown bug.

@pwojcikdev pwojcikdev force-pushed the networking-fixes-tcp-channels branch from 82e92cd to 8bfb8af Compare March 16, 2024 17:24
Copy link
Contributor

@clemahieu clemahieu left a comment

Choose a reason for hiding this comment

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

There are a lot of changes but generally moving to threads from queued periodic tasks and general cleanup of networking code is needed.

nano::unique_lock<nano::mutex> lock{ mutex };
while (!stopped)
{
condition.wait_for (lock, node.network_params.network.keepalive_period);
Copy link
Contributor

Choose a reason for hiding this comment

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

It probably doesn't make much of a difference but wait_for can spurriously wake up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a good point. Here I wanted something that works and is simple to implement. It should be trivial to implement a helper that ensures the interval is always respected. Adding this to my todo list.

nano/node/transport/tcp.cpp Show resolved Hide resolved
@@ -55,7 +55,7 @@ namespace transport
class tcp_server;
class tcp_channels;

class channel_tcp : public nano::transport::channel
class channel_tcp : public nano::transport::channel, public std::enable_shared_from_this<channel_tcp>
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe enable_shared_from_this should be on the base class nano::transport::channel?

Copy link
Contributor Author

@pwojcikdev pwojcikdev Mar 17, 2024

Choose a reason for hiding this comment

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

I'm not aware of an easy way to get shared_from_this working with a base class, is there any? From what I understand a form of CRTP pattern will be needed, is this the best way?

nano/node/node.cpp Show resolved Hide resolved
@pwojcikdev pwojcikdev merged commit 9b38bb2 into nanocurrency:develop Mar 18, 2024
19 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.

2 participants