From 62bbce76f2a19532870144c01778a81144443db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Thu, 29 Mar 2018 11:40:04 -0400 Subject: [PATCH] scheduler: avoid overflow causing 100% cpu usage --- src/dht_proxy_server.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dht_proxy_server.cpp b/src/dht_proxy_server.cpp index 0b77f96c..034dc524 100644 --- a/src/dht_proxy_server.cpp +++ b/src/dht_proxy_server.cpp @@ -124,7 +124,10 @@ DhtProxyServer::DhtProxyServer(std::shared_ptr<DhtRunner> dht, in_port_t port , while (service_->is_up() and not stopListeners) { std::unique_lock<std::mutex> lock(schedulerLock_); auto next = scheduler_.run(); - schedulerCv_.wait_until(lock, next); + if (next == time_point::max()) + schedulerCv_.wait(lock); + else + schedulerCv_.wait_until(lock, next); } }); -- GitLab