Skip to content

Commit

Permalink
Properly close channel container
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 16, 2024
1 parent db5f785 commit ef81c25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion nano/node/transport/tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ void nano::transport::tcp_channels::stop ()

message_manager.stop ();

// Close all TCP sockets
close ();
}

void nano::transport::tcp_channels::close ()
{
nano::lock_guard<nano::mutex> lock{ mutex };

for (auto const & channel : channels)
{
if (channel.socket)
Expand All @@ -163,6 +169,7 @@ void nano::transport::tcp_channels::stop ()
channel.response_server->stop ();
}
}

channels.clear ();
}

Expand Down
1 change: 1 addition & 0 deletions nano/node/transport/tcp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ namespace transport
void start ();
void stop ();

void close ();
bool insert (std::shared_ptr<nano::transport::channel_tcp> const &, std::shared_ptr<nano::transport::socket> const &, std::shared_ptr<nano::transport::tcp_server> const &);
void erase (nano::tcp_endpoint const &);
std::size_t size () const;
Expand Down

0 comments on commit ef81c25

Please sign in to comment.