Node id handshake container not protected during push (#2402)
* Node id handshake container not protected during push * Use nano::lock_guard not std::lock_guard
This commit is contained in:
		
					parent
					
						
							
								5295cf63ea
							
						
					
				
			
			
				commit
				
					
						94fb929f2c
					
				
			
		
					 2 changed files with 10 additions and 3 deletions
				
			
		| 
						 | 
					@ -484,7 +484,13 @@ bool nano::transport::tcp_channels::node_id_handhake_sockets_empty () const
 | 
				
			||||||
	return node_id_handshake_sockets.empty ();
 | 
						return node_id_handshake_sockets.empty ();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void nano::transport::tcp_channels::remove_node_id_handshake_socket (std::shared_ptr<nano::socket> socket_a)
 | 
					void nano::transport::tcp_channels::push_node_id_handshake_socket (std::shared_ptr<nano::socket> const & socket_a)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						nano::lock_guard<std::mutex> guard (mutex);
 | 
				
			||||||
 | 
						node_id_handshake_sockets.push_back (socket_a);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void nano::transport::tcp_channels::remove_node_id_handshake_socket (std::shared_ptr<nano::socket> const & socket_a)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	std::weak_ptr<nano::node> node_w (node.shared ());
 | 
						std::weak_ptr<nano::node> node_w (node.shared ());
 | 
				
			||||||
	if (auto node_l = node_w.lock ())
 | 
						if (auto node_l = node_w.lock ())
 | 
				
			||||||
| 
						 | 
					@ -521,7 +527,7 @@ void nano::transport::tcp_channels::start_tcp (nano::endpoint const & endpoint_a
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				std::shared_ptr<std::vector<uint8_t>> receive_buffer (std::make_shared<std::vector<uint8_t>> ());
 | 
									std::shared_ptr<std::vector<uint8_t>> receive_buffer (std::make_shared<std::vector<uint8_t>> ());
 | 
				
			||||||
				receive_buffer->resize (256);
 | 
									receive_buffer->resize (256);
 | 
				
			||||||
				node_l->network.tcp_channels.node_id_handshake_sockets.push_back (socket);
 | 
									node_l->network.tcp_channels.push_node_id_handshake_socket (socket);
 | 
				
			||||||
				channel->send_buffer (bytes, nano::stat::detail::node_id_handshake, [node_w, channel, endpoint_a, receive_buffer, callback_a](boost::system::error_code const & ec, size_t size_a) {
 | 
									channel->send_buffer (bytes, nano::stat::detail::node_id_handshake, [node_w, channel, endpoint_a, receive_buffer, callback_a](boost::system::error_code const & ec, size_t size_a) {
 | 
				
			||||||
					if (auto node_l = node_w.lock ())
 | 
										if (auto node_l = node_w.lock ())
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -104,7 +104,8 @@ namespace transport
 | 
				
			||||||
		void start_tcp (nano::endpoint const &, std::function<void(std::shared_ptr<nano::transport::channel>)> const & = nullptr);
 | 
							void start_tcp (nano::endpoint const &, std::function<void(std::shared_ptr<nano::transport::channel>)> const & = nullptr);
 | 
				
			||||||
		void start_tcp_receive_node_id (std::shared_ptr<nano::transport::channel_tcp>, nano::endpoint const &, std::shared_ptr<std::vector<uint8_t>>, std::function<void(std::shared_ptr<nano::transport::channel>)> const &);
 | 
							void start_tcp_receive_node_id (std::shared_ptr<nano::transport::channel_tcp>, nano::endpoint const &, std::shared_ptr<std::vector<uint8_t>>, std::function<void(std::shared_ptr<nano::transport::channel>)> const &);
 | 
				
			||||||
		void udp_fallback (nano::endpoint const &, std::function<void(std::shared_ptr<nano::transport::channel>)> const &);
 | 
							void udp_fallback (nano::endpoint const &, std::function<void(std::shared_ptr<nano::transport::channel>)> const &);
 | 
				
			||||||
		void remove_node_id_handshake_socket (std::shared_ptr<nano::socket> socket_a);
 | 
							void push_node_id_handshake_socket (std::shared_ptr<nano::socket> const & socket_a);
 | 
				
			||||||
 | 
							void remove_node_id_handshake_socket (std::shared_ptr<nano::socket> const & socket_a);
 | 
				
			||||||
		bool node_id_handhake_sockets_empty () const;
 | 
							bool node_id_handhake_sockets_empty () const;
 | 
				
			||||||
		nano::node & node;
 | 
							nano::node & node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue