[PATCH 26/38] virlog: Swap the new copy of outputs with the global existing one

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

 



Actually perform the swap between the active set of outputs and the
user-provided copy. Deallocation ensures that no file descriptors that should
not have been closed are not closed and all descriptors that should be closed
are closed properly.
---
 src/util/virlog.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/util/virlog.c b/src/util/virlog.c
index a20cde4..8e14a9e 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1641,22 +1641,29 @@ virLogSetOutputs(const char *outputs)
  * @outputs: new set of outputs to be defined
  * @noutputs: number of outputs in @outputs
  *
- * Resets any existing set of outputs and defines a completely new one.
+ * Swaps any existing set of outputs with a completely new one.
  *
  * Returns number of outputs successfully defined or -1 in case of error;
  */
 int
 virLogDefineOutputs(virLogOutputPtr *outputs, size_t noutputs)
 {
+    size_t count;
+    virLogOutputPtr *tmp = NULL;
+
     if (virLogInitialize() < 0)
         return -1;
 
     virLogLock();
-    virLogResetOutputs();
+    /* swap the currently defined list with a new copy and  */
+    tmp = virLogOutputs;
+    count = virLogNbOutputs;
     virLogOutputs = outputs;
     virLogNbOutputs = noutputs;
     virLogUnlock();
 
+    virLogOutputListFree(tmp, count);
+
     return virLogNbOutputs;
 }
 
-- 
2.4.3

--
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]