Networking cleanup continued#4495
Conversation
82e92cd to
8bfb8af
Compare
d25037a to
0d61dba
Compare
clemahieu
left a comment
There was a problem hiding this comment.
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.
It probably doesn't make much of a difference but wait_for can spurriously wake up.
There was a problem hiding this comment.
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.
| 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.
Maybe enable_shared_from_this should be on the base class nano::transport::channel?
There was a problem hiding this comment.
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_channelsclass. It eliminates some obvious inefficiencies (theupdatefunction), offloads peer reachout loop to a dedicated thread and fixes shutdown bug.