Skip to content

Commit

Permalink
Add timeout for run_next ()
Browse files Browse the repository at this point in the history
  • Loading branch information
SergiySW committed Mar 7, 2020
1 parent b1e9d6a commit e28dad0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions nano/node/bootstrap/bootstrap_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,19 @@ void nano::bootstrap_server::run_next (nano::unique_lock<std::mutex> & 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<nano::bootstrap_server> 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 ();
}
});
}
}
}

Expand Down

0 comments on commit e28dad0

Please sign in to comment.