]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libvirtd: fix bug when shrinking number of clients
authorEric Blake <eblake@redhat.com>
Mon, 22 Nov 2010 19:27:07 +0000 (12:27 -0700)
committerEric Blake <eblake@redhat.com>
Tue, 23 Nov 2010 15:43:00 +0000 (08:43 -0700)
* daemon/libvirtd.c (qemudRunLoop): Pass allocation size, not
current count, to VIR_SHRINK_N.
* docs/hacking.html.in: Update doc example.
* HACKING: Regenerate.

HACKING
daemon/libvirtd.c
docs/hacking.html.in

diff --git a/HACKING b/HACKING
index 35ceb29822f0c4381f9ea4d850b27239dbaef0d5..cd7559d586f9bb8f20b4f6a215ad558c88a39df6 100644 (file)
--- a/HACKING
+++ b/HACKING
@@ -347,13 +347,14 @@ scales better, but requires tracking allocation separately from usage)
 
 
 
-- To trim an array of domains to have one less element:
+- To trim an array of domains from its allocated size down to the actual used
+size:
 
   virDomainPtr domains;
   size_t ndomains = x;
   size_t ndomains_max = y;
 
-  VIR_SHRINK_N(domains, ndomains_max, 1);
+  VIR_SHRINK_N(domains, ndomains_max, ndomains_max - ndomains);
 
 
 
index 2eb2374134811b30774f4c4a09c1b4be640f8e5b..66f1388619e2e700986488141f0fc44407e06ced 100644 (file)
@@ -2362,7 +2362,8 @@ static void *qemudRunLoop(void *opaque) {
                             server->clients + i + 1,
                             sizeof (*server->clients) * (server->nclients - i));
 
-                VIR_SHRINK_N(server->clients, server->nclients, 0);
+                VIR_SHRINK_N(server->clients, server->nclients_max,
+                             server->nclients_max - server->nclients);
                 goto reprocess;
             }
         }
index 890692f05803c5e37778face4f03e82fd5e47768..ac16f411b5c633f2c54ecd2f0b7962665084477e 100644 (file)
 </pre>
       </li>
 
-      <li><p>To trim an array of domains to have one less element:</p>
+      <li><p>To trim an array of domains from its allocated size down
+      to the actual used size:</p>
 
 <pre>
   virDomainPtr domains;
   size_t ndomains = x;
   size_t ndomains_max = y;
 
-  VIR_SHRINK_N(domains, ndomains_max, 1);
+  VIR_SHRINK_N(domains, ndomains_max, ndomains_max - ndomains);
 </pre></li>
 
       <li><p>To free an array of domains:</p>