7a3408
From c6ea8b7cb4d2b56f29b791a5f2ee492b4e2bc055 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <c6ea8b7cb4d2b56f29b791a5f2ee492b4e2bc055@dist-git>
7a3408
From: Martin Kletzander <mkletzan@redhat.com>
7a3408
Date: Wed, 15 Jul 2015 17:11:56 +0200
7a3408
Subject: [PATCH] rpc: Rework timerActive logic in daemon
7a3408
7a3408
Daemon used false logic for determining whether there were any clients.
7a3408
When the timer was inactive, it was activated if at least one of the
7a3408
servers did not have clients.  So the bool was being flipped there and
7a3408
back all the time in case there was one client, for example.
7a3408
7a3408
Initially introduced by fa1420736882.
7a3408
7a3408
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1240283
7a3408
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
(cherry picked from commit b7ea58c262194037042284a14fb1608c9cf31884)
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/rpc/virnetdaemon.c | 24 +++++++++---------------
7a3408
 1 file changed, 9 insertions(+), 15 deletions(-)
7a3408
7a3408
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
7a3408
index 6b13282..910f266 100644
7a3408
--- a/src/rpc/virnetdaemon.c
7a3408
+++ b/src/rpc/virnetdaemon.c
7a3408
@@ -682,23 +682,17 @@ virNetDaemonRun(virNetDaemonPtr dmn)
7a3408
          */
7a3408
         if (dmn->autoShutdownTimeout) {
7a3408
             if (timerActive) {
7a3408
-                for (i = 0; i < dmn->nservers; i++) {
7a3408
-                    if (virNetServerHasClients(dmn->servers[i])) {
7a3408
-                        VIR_DEBUG("Deactivating shutdown timer %d", timerid);
7a3408
-                        virEventUpdateTimeout(timerid, -1);
7a3408
-                        timerActive = false;
7a3408
-                        break;
7a3408
-                    }
7a3408
+                if (virNetDaemonHasClients(dmn)) {
7a3408
+                    VIR_DEBUG("Deactivating shutdown timer %d", timerid);
7a3408
+                    virEventUpdateTimeout(timerid, -1);
7a3408
+                    timerActive = false;
7a3408
                 }
7a3408
             } else {
7a3408
-                for (i = 0; i < dmn->nservers; i++) {
7a3408
-                    if (!virNetServerHasClients(dmn->servers[i])) {
7a3408
-                        VIR_DEBUG("Activating shutdown timer %d", timerid);
7a3408
-                        virEventUpdateTimeout(timerid,
7a3408
-                                              dmn->autoShutdownTimeout * 1000);
7a3408
-                        timerActive = true;
7a3408
-                        break;
7a3408
-                    }
7a3408
+                if (!virNetDaemonHasClients(dmn)) {
7a3408
+                    VIR_DEBUG("Activating shutdown timer %d", timerid);
7a3408
+                    virEventUpdateTimeout(timerid,
7a3408
+                                          dmn->autoShutdownTimeout * 1000);
7a3408
+                    timerActive = true;
7a3408
                 }
7a3408
             }
7a3408
         }
7a3408
-- 
7a3408
2.5.0
7a3408