Fix console queue behavior (was broken by recent changes).
authorDavin McCall <davmac@davmac.org>
Mon, 12 Jun 2017 21:25:57 +0000 (22:25 +0100)
committerDavin McCall <davmac@davmac.org>
Mon, 12 Jun 2017 21:25:57 +0000 (22:25 +0100)
src/service.h

index 8b052d857eadc14fec8aecac026b20b2d623d67c..6417e5526fceaa2abefb1944d3bfda7e2eb6368b 100644 (file)
@@ -871,15 +871,23 @@ class ServiceSet
     // Set the console queue tail (returns previous tail)
     void append_console_queue(ServiceRecord * newTail) noexcept
     {
-        if (! console_queue.is_queued(newTail)) {
-            console_queue.append(newTail);
+        bool was_empty = console_queue.is_empty();
+        console_queue.append(newTail);
+        if (was_empty) {
+            enable_console_log(false);
         }
     }
     
-    // Retrieve the current console queue head and remove it from the queue
-    ServiceRecord * pull_console_queue() noexcept
+    // Pull and dispatch a waiter from the console queue
+    void pull_console_queue() noexcept
     {
-        return console_queue.pop_front();
+        if (console_queue.is_empty()) {
+            enable_console_log(true);
+        }
+        else {
+            ServiceRecord * front = console_queue.pop_front();
+            front->acquiredConsole();
+        }
     }
     
     void unqueue_console(ServiceRecord * service) noexcept