MCPcopy Create free account
hub / github.com/bitshares/bitshares-core / accept_loop

Method accept_loop

libraries/net/node.cpp:4022–4052  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4020 }
4021
4022 void node_impl::accept_loop()
4023 {
4024 VERIFY_CORRECT_THREAD();
4025 while ( !_accept_loop_complete.canceled() )
4026 {
4027 peer_connection_ptr new_peer(peer_connection::make_shared(this));
4028
4029 try
4030 {
4031 _tcp_server.accept( new_peer->get_socket() );
4032 ilog( "accepted inbound connection from ${remote_endpoint}",
4033 ("remote_endpoint", new_peer->get_socket().remote_endpoint() ) );
4034 if (_node_is_shutting_down)
4035 return;
4036 new_peer->connection_initiation_time = fc::time_point::now();
4037 _handshaking_connections.insert( new_peer );
4038 _rate_limiter.add_tcp_socket( &new_peer->get_socket() );
4039 std::weak_ptr<peer_connection> new_weak_peer(new_peer);
4040 new_peer->accept_or_connect_task_done = fc::async( [this, new_weak_peer]() {
4041 peer_connection_ptr new_peer(new_weak_peer.lock());
4042 assert(new_peer);
4043 if (!new_peer)
4044 return;
4045 accept_connection_task(new_peer);
4046 }, "accept_connection_task" );
4047
4048 // limit the rate at which we accept connections to mitigate DOS attacks
4049 fc::usleep( fc::milliseconds(10) );
4050 } FC_CAPTURE_AND_LOG( (0) ) // GCOVR_EXCL_LINE
4051 }
4052 } // accept_loop()
4053
4054 void node_impl::send_hello_message(const peer_connection_ptr& peer)
4055 {

Callers

nothing calls this directly

Calls 2

lockMethod · 0.80
acceptMethod · 0.45

Tested by

no test coverage detected