]> xenbits.xensource.com Git - libvirt.git/commitdiff
rpc: Rework timerActive logic in daemon
authorMartin Kletzander <mkletzan@redhat.com>
Fri, 10 Jul 2015 08:35:31 +0000 (10:35 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Fri, 10 Jul 2015 09:13:29 +0000 (11:13 +0200)
Daemon used false logic for determining whether there were any clients.
When the timer was inactive, it was activated if at least one of the
servers did not have clients.  So the bool was being flipped there and
back all the time in case there was one client, for example.

Initially introduced by fa1420736882.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1240283

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/rpc/virnetdaemon.c

index 6b132823274c31af2a0d60b8a0298ca31ef8c7e2..910f2662079bd42ee432e58be41997a97d98b3bc 100644 (file)
@@ -682,23 +682,17 @@ virNetDaemonRun(virNetDaemonPtr dmn)
          */
         if (dmn->autoShutdownTimeout) {
             if (timerActive) {
-                for (i = 0; i < dmn->nservers; i++) {
-                    if (virNetServerHasClients(dmn->servers[i])) {
-                        VIR_DEBUG("Deactivating shutdown timer %d", timerid);
-                        virEventUpdateTimeout(timerid, -1);
-                        timerActive = false;
-                        break;
-                    }
+                if (virNetDaemonHasClients(dmn)) {
+                    VIR_DEBUG("Deactivating shutdown timer %d", timerid);
+                    virEventUpdateTimeout(timerid, -1);
+                    timerActive = false;
                 }
             } else {
-                for (i = 0; i < dmn->nservers; i++) {
-                    if (!virNetServerHasClients(dmn->servers[i])) {
-                        VIR_DEBUG("Activating shutdown timer %d", timerid);
-                        virEventUpdateTimeout(timerid,
-                                              dmn->autoShutdownTimeout * 1000);
-                        timerActive = true;
-                        break;
-                    }
+                if (!virNetDaemonHasClients(dmn)) {
+                    VIR_DEBUG("Activating shutdown timer %d", timerid);
+                    virEventUpdateTimeout(timerid,
+                                          dmn->autoShutdownTimeout * 1000);
+                    timerActive = true;
                 }
             }
         }