]> xenbits.xensource.com Git - libvirt.git/commitdiff
rpc: virnetserver: Move virNetServerCheckLimits which is static up in the file
authorErik Skultety <eskultet@redhat.com>
Wed, 20 Jul 2016 08:17:19 +0000 (10:17 +0200)
committerErik Skultety <eskultet@redhat.com>
Tue, 2 Aug 2016 12:51:13 +0000 (14:51 +0200)
Since virNetServerAddClient checks for the limits in order to temporarily
suspend the services, thus not accepting any more clients, there is no reason
why virNetServerCheckLimits, which is only responsible for re-enabling
previously disabled services according to the limits, could not do both. To be
able to do that however, it needs to be moved up in the file since it's static
(and because it's just a helper and there's only one caller it should remain
 static).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
src/rpc/virnetserver.c

index 13b5bd378c540ca85fb96d31f71bd90f017a9c8b..0c502d95572572f35096de7d8167e3810ffd5961 100644 (file)
@@ -234,6 +234,34 @@ static int virNetServerDispatchNewMessage(virNetServerClientPtr client,
     return ret;
 }
 
+/**
+ * virNetServerCheckLimits:
+ * @srv: server to check limits on
+ *
+ * Check if limits like max_clients or max_anonymous_clients
+ * are satisfied and if so, re-enable accepting new clients.
+ * The @srv must be locked when this function is called.
+ */
+static void
+virNetServerCheckLimits(virNetServerPtr srv)
+{
+    /* Enable services if we can accept a new client.
+     * The new client can be accepted if both max_clients and
+     * max_anonymous_clients wouldn't get overcommitted by
+     * accepting it. */
+    VIR_DEBUG("Considering re-enabling services: "
+              "nclients=%zu nclients_max=%zu "
+              "nclients_unauth=%zu nclients_unauth_max=%zu",
+              srv->nclients, srv->nclients_max,
+              srv->nclients_unauth, srv->nclients_unauth_max);
+    if (srv->nclients < srv->nclients_max &&
+        (!srv->nclients_unauth_max ||
+         srv->nclients_unauth < srv->nclients_unauth_max)) {
+        /* Now it makes sense to accept() a new client. */
+        VIR_INFO("Re-enabling services");
+        virNetServerUpdateServicesLocked(srv, true);
+    }
+}
 
 int virNetServerAddClient(virNetServerPtr srv,
                           virNetServerClientPtr client)
@@ -737,35 +765,6 @@ void virNetServerUpdateServices(virNetServerPtr srv,
     virObjectUnlock(srv);
 }
 
-/**
- * virNetServerCheckLimits:
- * @srv: server to check limits on
- *
- * Check if limits like max_clients or max_anonymous_clients
- * are satisfied and if so, re-enable accepting new clients.
- * The @srv must be locked when this function is called.
- */
-static void
-virNetServerCheckLimits(virNetServerPtr srv)
-{
-    /* Enable services if we can accept a new client.
-     * The new client can be accepted if both max_clients and
-     * max_anonymous_clients wouldn't get overcommitted by
-     * accepting it. */
-    VIR_DEBUG("Considering re-enabling services: "
-              "nclients=%zu nclients_max=%zu "
-              "nclients_unauth=%zu nclients_unauth_max=%zu",
-              srv->nclients, srv->nclients_max,
-              srv->nclients_unauth, srv->nclients_unauth_max);
-    if (srv->nclients < srv->nclients_max &&
-        (!srv->nclients_unauth_max ||
-         srv->nclients_unauth < srv->nclients_unauth_max)) {
-        /* Now it makes sense to accept() a new client. */
-        VIR_INFO("Re-enabling services");
-        virNetServerUpdateServicesLocked(srv, true);
-    }
-}
-
 void virNetServerDispose(void *obj)
 {
     virNetServerPtr srv = obj;