[PATCH 4/5] libvirtd: Alter refcnt processing for server program objects

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

 



Instead of holding onto the reference for each program added to
a NetServer, let's Unref the program reference as soon as the
attempt is made to add to the @srv->programs list. This then
allows the virNetServerDispose to handle the final Unref of
the object for actual deletion and cleans up the cleanup: path.

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

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 5c47e49d48..87c5b22710 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1352,7 +1352,10 @@ int main(int argc, char **argv) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
-    if (virNetServerAddProgram(srv, remoteProgram) < 0) {
+
+    rc = virNetServerAddProgram(srv, remoteProgram);
+    virObjectUnref(remoteProgram);
+    if (rc < 0) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
@@ -1364,7 +1367,10 @@ int main(int argc, char **argv) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
-    if (virNetServerAddProgram(srv, lxcProgram) < 0) {
+
+    rc = virNetServerAddProgram(srv, lxcProgram);
+    virObjectUnref(lxcProgram);
+    if (rc < 0) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
@@ -1376,7 +1382,10 @@ int main(int argc, char **argv) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
-    if (virNetServerAddProgram(srv, qemuProgram) < 0) {
+
+    rc = virNetServerAddProgram(srv, qemuProgram);
+    virObjectUnref(qemuProgram);
+    if (rc < 0) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
@@ -1414,7 +1423,10 @@ int main(int argc, char **argv) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
-    if (virNetServerAddProgram(srvAdm, adminProgram) < 0) {
+
+    rc = virNetServerAddProgram(srvAdm, adminProgram);
+    virObjectUnref(adminProgram);
+    if (rc < 0) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
     }
@@ -1513,10 +1525,6 @@ int main(int argc, char **argv) {
 
  cleanup:
     virNetlinkEventServiceStopAll();
-    virObjectUnref(remoteProgram);
-    virObjectUnref(lxcProgram);
-    virObjectUnref(qemuProgram);
-    virObjectUnref(adminProgram);
     virNetDaemonClose(dmn);
     virNetlinkShutdown();
     if (statuswrite != -1) {
-- 
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