| 1270 | } |
| 1271 | |
| 1272 | void accept_loop() |
| 1273 | { |
| 1274 | while (!_accept_loop_complete.canceled()) |
| 1275 | { |
| 1276 | fc::tcp_socket_ptr sock = std::make_shared<fc::tcp_socket>(); |
| 1277 | try |
| 1278 | { |
| 1279 | _tcp_serv->accept(*sock); |
| 1280 | } |
| 1281 | catch (const fc::canceled_exception&) |
| 1282 | { |
| 1283 | throw; |
| 1284 | } |
| 1285 | catch (const fc::exception& e) |
| 1286 | { |
| 1287 | elog("fatal: error opening socket for rpc connection: ${e}", ("e", e.to_detail_string())); |
| 1288 | continue; |
| 1289 | } |
| 1290 | |
| 1291 | auto buf_istream = std::make_shared<fc::buffered_istream>(sock); |
| 1292 | auto buf_ostream = std::make_shared<fc::buffered_ostream>(sock); |
| 1293 | |
| 1294 | auto json_con = std::make_shared<fc::rpc::json_connection>(std::move(buf_istream), |
| 1295 | std::move(buf_ostream)); |
| 1296 | register_methods(json_con); |
| 1297 | auto receipt = _open_json_connections.insert(json_con); |
| 1298 | |
| 1299 | json_con->exec().on_complete([this, receipt, sock](fc::exception_ptr e){ |
| 1300 | ilog("json_con exited"); |
| 1301 | sock->close(); |
| 1302 | _open_json_connections.erase(receipt.first); |
| 1303 | if (e) |
| 1304 | elog("Connection exited with error: ${error}", ("error", e->what())); |
| 1305 | }); |
| 1306 | } |
| 1307 | } |
| 1308 | |
| 1309 | void encrypted_accept_loop(const thinkyoung::blockchain::PrivateKeyType& server_key) |
| 1310 | { |
no test coverage detected