Skip to content

Commit

Permalink
Fix tcp_socket::type() race (#4775)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev authored Oct 28, 2024
1 parent 104b74d commit 78f8eea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit 78f8eea

Please sign in to comment.