Fix for the bootstrap request queue processing (#3461)

This commit is contained in:
theohax 2021-09-21 23:14:07 +03:00 committed by GitHub
commit 4255a384f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -551,12 +551,19 @@ void nano::bootstrap_server::finish_request ()
{ {
nano::unique_lock<nano::mutex> lock (mutex); nano::unique_lock<nano::mutex> lock (mutex);
requests.pop (); requests.pop ();
if (!requests.empty ())
while (!requests.empty ())
{ {
run_next (lock); if (!requests.front ())
{
requests.pop ();
} }
else else
{ {
run_next (lock);
}
}
std::weak_ptr<nano::bootstrap_server> this_w (shared_from_this ()); std::weak_ptr<nano::bootstrap_server> this_w (shared_from_this ());
node->workers.add_timed_task (std::chrono::steady_clock::now () + (node->config.tcp_io_timeout * 2) + std::chrono::seconds (1), [this_w] () { node->workers.add_timed_task (std::chrono::steady_clock::now () + (node->config.tcp_io_timeout * 2) + std::chrono::seconds (1), [this_w] () {
if (auto this_l = this_w.lock ()) if (auto this_l = this_w.lock ())
@ -564,7 +571,6 @@ void nano::bootstrap_server::finish_request ()
this_l->timeout (); this_l->timeout ();
} }
}); });
}
} }
void nano::bootstrap_server::finish_request_async () void nano::bootstrap_server::finish_request_async ()
@ -725,19 +731,9 @@ void nano::bootstrap_server::run_next (nano::unique_lock<nano::mutex> & lock_a)
// Realtime // Realtime
auto request (std::move (requests.front ())); auto request (std::move (requests.front ()));
requests.pop (); requests.pop ();
auto timeout_check (requests.empty ());
lock_a.unlock (); lock_a.unlock ();
request->visit (visitor); request->visit (visitor);
if (timeout_check) lock_a.lock ();
{
std::weak_ptr<nano::bootstrap_server> this_w (shared_from_this ());
node->workers.add_timed_task (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 ();
}
});
}
} }
} }