Skip to content

Commit

Permalink
Properly initialize array of atomics in ws server (#3020)
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptocode authored Oct 26, 2020
1 parent 15d0649 commit 25e952d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions nano/node/websocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ socket (io_ctx_a)
{
try
{
for (std::atomic<std::size_t> & item : topic_subscriber_count)
{
item = std::size_t (0);
}
acceptor.open (endpoint_a.protocol ());
acceptor.set_option (boost::asio::socket_base::reuse_address (true));
acceptor.bind (endpoint_a);
Expand Down
2 changes: 1 addition & 1 deletion nano/node/websocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ namespace websocket
socket_type socket;
std::mutex sessions_mutex;
std::vector<std::weak_ptr<session>> sessions;
std::array<std::atomic<std::size_t>, number_topics> topic_subscriber_count{};
std::array<std::atomic<std::size_t>, number_topics> topic_subscriber_count;
std::atomic<bool> stopped{ false };
};
}
Expand Down

0 comments on commit 25e952d

Please sign in to comment.