Skip to content
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

Fix tcp_socket::type() race #4775

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nano/node/transport/tcp_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ void nano::transport::tcp_socket::operator() (nano::object_stream & obs) const
{
obs.write ("remote_endpoint", remote_endpoint ());
obs.write ("local_endpoint", local_endpoint ());
obs.write ("type", type_m);
obs.write ("type", type_m.load ());
obs.write ("endpoint_type", endpoint_type_m);
}

Expand Down
8 changes: 4 additions & 4 deletions nano/node/transport/tcp_socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ class tcp_socket final : public std::enable_shared_from_this<tcp_socket>
{
return type_m;
};
void type_set (nano::transport::socket_type type_a)
void type_set (nano::transport::socket_type type)
{
type_m = type_a;
type_m = type;
}
nano::transport::socket_endpoint endpoint_type () const
{
Expand Down Expand Up @@ -195,8 +195,8 @@ class tcp_socket final : public std::enable_shared_from_this<tcp_socket>
void read_impl (std::shared_ptr<std::vector<uint8_t>> const & data_a, std::size_t size_a, std::function<void (boost::system::error_code const &, std::size_t)> callback_a);

private:
nano::transport::socket_type type_m{ socket_type::undefined };
nano::transport::socket_endpoint endpoint_type_m;
socket_endpoint const endpoint_type_m;
std::atomic<socket_type> type_m{ socket_type::undefined };

public:
std::size_t const max_queue_size;
Expand Down
Loading