From e28dad0266107b04e7b7701ea53b9760f496f1ca Mon Sep 17 00:00:00 2001 From: Sergey Kroshnin Date: Sat, 7 Mar 2020 04:33:34 +0300 Subject: [PATCH] Add timeout for run_next () --- nano/node/bootstrap/bootstrap_server.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nano/node/bootstrap/bootstrap_server.cpp b/nano/node/bootstrap/bootstrap_server.cpp index d78900e49f..7cae35b34f 100644 --- a/nano/node/bootstrap/bootstrap_server.cpp +++ b/nano/node/bootstrap/bootstrap_server.cpp @@ -692,8 +692,19 @@ void nano::bootstrap_server::run_next (nano::unique_lock & lock_a) // Realtime auto request (std::move (requests.front ())); requests.pop (); + auto timeout_check (requests.empty ()); lock_a.unlock (); request->visit (visitor); + if (timeout_check) + { + std::weak_ptr this_w (shared_from_this ()); + node->alarm.add (std::chrono::steady_clock::now () + (node->config.tcp_io_timeout * 2) + std::chrono::seconds (1), [this_w]() { + if (auto this_l = this_w.lock ()) + { + this_l->timeout (); + } + }); + } } }