From 29f3b23eb30af1ad8d09ec23d5fd896b0644115d Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 10 Oct 2020 22:46:42 +0200 Subject: [PATCH] api: fixed busy-polling of worker --- lib/api.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/api.cpp b/lib/api.cpp index cc4d20e60..1050266ff 100644 --- a/lib/api.cpp +++ b/lib/api.cpp @@ -88,16 +88,14 @@ void Api::worker() { logger->info("Started worker"); - while (running) { - /* Process pending requests */ - while (!pending.empty()) { - Session *s = pending.pop(); - if (s) { - /* Check that the session is still alive */ - auto it = std::find(sessions.begin(), sessions.end(), s); - if (it != sessions.end()) - s->execute(); - } + /* Process pending requests */ + while (!pending.empty() && running) { + Session *s = pending.pop(); + if (s) { + /* Check that the session is still alive */ + auto it = std::find(sessions.begin(), sessions.end(), s); + if (it != sessions.end()) + s->execute(); } }