-
Notifications
You must be signed in to change notification settings - Fork 791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Networking cleanup continued #4495
Networking cleanup continued #4495
Conversation
82e92cd
to
8bfb8af
Compare
d25037a
to
0d61dba
Compare
There was a problem hiding this 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/node/transport/tcp.cpp
Outdated
nano::unique_lock<nano::mutex> lock{ mutex }; | ||
while (!stopped) | ||
{ | ||
condition.wait_for (lock, node.network_params.network.keepalive_period); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@@ -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> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
This PR focuses on cleanup of
tcp_channels
class. It eliminates some obvious inefficiencies (theupdate
function), offloads peer reachout loop to a dedicated thread and fixes shutdown bug.