[libvirt] [PATCH 6/n] libvirtd: avoid memory leak on shutdown

Eric Blake eblake at redhat.com
Tue Nov 30 19:06:12 UTC 2010


* daemon/libvirtd.c (qemudRunLoop): Free any remaining client data.
---

Since qemudCleanup calls VIR_FREE(server), it only makes sense to
first free all of server's contents.

Probably not the most important leak to plug (it only triggers at
libvirtd exit, where the memory would be abandoned by process exit
anyways, and does not affect clients that link against libvirt as
a library), but plugging it makes leak analysis of the rest of
libvirtd easier.

 daemon/libvirtd.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index caf51bf..791b3dc 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -2403,6 +2403,10 @@ cleanup:
         server->workers[i].hasThread = 0;
     }
     VIR_FREE(server->workers);
+    for (i = 0; i < server->nclients; i++)
+        qemudFreeClient(server->clients[i]);
+    server->nclients = 0;
+    VIR_SHRINK_N(server->clients, server->nclients_max, server->nclients_max);

     virMutexUnlock(&server->lock);
     return NULL;
-- 
1.7.3.2




More information about the libvir-list mailing list