[RFC PATCH 02/10] libvirtd: Alter refcnt processing for server program objects

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

 



Once virNetServerProgramNew returns, the program objects have
either been added to the @srv or @srvAdm list increasing the
refcnt or there was an error. In either case, we can lower the
refcnt from virNetServerProgramNew and set the object to NULL
since it won't be used any more.

The @srv or @srvAdm dispose function (virNetServerDispose) will
handle the Unref of each object during the virHashFree when the
object is removed from the hash table.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 daemon/libvirtd.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 0afd1dd82..b47f875d9 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1352,7 +1352,11 @@ int main(int argc, char **argv) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
-    if (virNetServerAddProgram(srv, remoteProgram) < 0) {
+
+    rc = virNetServerAddProgram(srv, remoteProgram);
+    virObjectUnref(remoteProgram);
+    remoteProgram = NULL;
+    if (rc < 0) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
@@ -1364,7 +1368,11 @@ int main(int argc, char **argv) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
-    if (virNetServerAddProgram(srv, lxcProgram) < 0) {
+
+    rc = virNetServerAddProgram(srv, lxcProgram);
+    virObjectUnref(lxcProgram);
+    lxcProgram = NULL;
+    if (rc < 0) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
@@ -1376,7 +1384,11 @@ int main(int argc, char **argv) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
-    if (virNetServerAddProgram(srv, qemuProgram) < 0) {
+
+    rc = virNetServerAddProgram(srv, qemuProgram);
+    virObjectUnref(qemuProgram);
+    qemuProgram = NULL;
+    if (rc < 0) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
@@ -1414,7 +1426,11 @@ int main(int argc, char **argv) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
-    if (virNetServerAddProgram(srvAdm, adminProgram) < 0) {
+
+    rc = virNetServerAddProgram(srvAdm, adminProgram);
+    virObjectUnref(adminProgram);
+    adminProgram = NULL;
+    if (rc < 0) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
@@ -1524,10 +1540,6 @@ int main(int argc, char **argv) {
         virStateCleanup();
     }
 
-    virObjectUnref(adminProgram);
-    virObjectUnref(qemuProgram);
-    virObjectUnref(lxcProgram);
-    virObjectUnref(remoteProgram);
     virObjectUnref(dmn);
 
     virNetlinkShutdown();
-- 
2.13.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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