MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / accept_loop

Method accept_loop

src/Chain/libraries/net/ChainServer.cpp:48–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 }
47
48 void accept_loop() {
49 while (!_accept_loop_handle.canceled()) {
50 fc::tcp_socket* connection_socket = new fc::tcp_socket;
51 _server_socket.accept(*connection_socket);
52 ilog("Got new connection from ${remote}", ("remote", connection_socket->remote_endpoint()));
53
54 auto worker_thread = get_worker();
55 if (worker_thread == nullptr) {
56 connection_socket->close();
57 delete connection_socket;
58 continue;
59 }
60 auto finished_future = worker_thread->async([=]{serve_client(connection_socket); }, "serve_client");
61 auto master_thread = &fc::thread::current();
62
63 finished_future.on_complete([=](fc::exception_ptr ep) { master_thread->async([=] {
64 _busy_threads.erase(worker_thread);
65 if ((int)_idle_threads.size() < _target_thread_count) {
66 _idle_threads.insert(worker_thread);
67 ilog("Resting thread; there are now ${i} idle and ${b} busy", ("i", _idle_threads.size())("b", _busy_threads.size()));
68 }
69 else
70 kill_worker(worker_thread);
71 }, "cleanup_chain_server_threads"); });
72 }
73 }
74
75 void handle_get_blocks_from_number(fc::tcp_socket& connection_socket) {
76 try {

Callers

nothing calls this directly

Calls 9

asyncMethod · 0.80
canceledMethod · 0.45
acceptMethod · 0.45
remote_endpointMethod · 0.45
closeMethod · 0.45
on_completeMethod · 0.45
eraseMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected