[libvirt PATCH 06/10] virNetServerProcessClients: Remove goto

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This gets rid of the goto and prepares the function for automatic
mutex management.

Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/rpc/virnetserver.c | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index d9430a2cfa..7824d121cd 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -960,13 +960,19 @@ virNetServerHasClients(virNetServer *srv)
 void
 virNetServerProcessClients(virNetServer *srv)
 {
-    size_t i;
-    virNetServerClient *client;
+    size_t i = 0;
 
-    virObjectLock(srv);
+    while (true) {
+        virNetServerClient *client;
+        bool removed = false;
+
+        virObjectLock(srv);
+
+        if (i >= srv->nclients) {
+            virObjectUnlock(srv);
+            return;
+        }
 
- reprocess:
-    for (i = 0; i < srv->nclients; i++) {
         client = srv->clients[i];
         virObjectLock(client);
         if (virNetServerClientWantCloseLocked(client))
@@ -974,24 +980,26 @@ virNetServerProcessClients(virNetServer *srv)
 
         if (virNetServerClientIsClosedLocked(client)) {
             VIR_DELETE_ELEMENT(srv->clients, i, srv->nclients);
+            removed = true;
 
             /* Update server authentication tracking */
             virNetServerSetClientAuthCompletedLocked(srv, client);
-            virObjectUnlock(client);
-
             virNetServerCheckLimits(srv);
+        }
+
+        virObjectUnlock(client);
 
+        if (removed) {
+            i = 0;
             virObjectUnlock(srv);
             virObjectUnref(client);
-            virObjectLock(srv);
-
-            goto reprocess;
-        } else {
-            virObjectUnlock(client);
+            continue;
         }
-    }
 
-    virObjectUnlock(srv);
+        i++;
+
+        virObjectUnlock(srv);
+    }
 }
 
 
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux