[PATCH] virtlockd: fix misc memory leaks and other bugs

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

 



Fix memory leaks, failure to restore umask and missing man
page docs.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/locking/lock_daemon.c    | 6 +++++-
 src/locking/virtlockd.pod.in | 7 ++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 3dc47c1..a5a40fe 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -118,6 +118,7 @@ virLockDaemonFree(virLockDaemonPtr lockd)
     if (!lockd)
         return;
 
+    virMutexDestroy(&lockd->lock);
     virObjectUnref(lockd->dmn);
     virHashFree(lockd->lockspaces);
     virLockSpaceFree(lockd->defaultLockspace);
@@ -410,6 +411,7 @@ virLockDaemonUnixSocketPaths(bool privileged,
 
         old_umask = umask(077);
         if (virFileMakePath(rundir) < 0) {
+            VIR_FREE(rundir);
             umask(old_umask);
             goto error;
         }
@@ -516,6 +518,7 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr config,
 
                 old_umask = umask(077);
                 if (virFileMakePath(logdir) < 0) {
+                    VIR_FREE(logdir);
                     umask(old_umask);
                     goto error;
                 }
@@ -1187,7 +1190,7 @@ int main(int argc, char **argv) {
         int c;
         char *tmp;
 
-        c = getopt_long(argc, argv, "ldf:p:t:vVh", opts, &optidx);
+        c = getopt_long(argc, argv, "df:p:t:vVh", opts, &optidx);
 
         if (c == -1)
             break;
@@ -1321,6 +1324,7 @@ int main(int argc, char **argv) {
         VIR_ERROR(_("unable to create rundir %s: %s"), run_dir,
                   virStrerror(errno, ebuf, sizeof(ebuf)));
         ret = VIR_LOCK_DAEMON_ERR_RUNDIR;
+        umask(old_umask);
         goto cleanup;
     }
     umask(old_umask);
diff --git a/src/locking/virtlockd.pod.in b/src/locking/virtlockd.pod.in
index 99612aa..661473c 100644
--- a/src/locking/virtlockd.pod.in
+++ b/src/locking/virtlockd.pod.in
@@ -4,7 +4,7 @@ virtlockd - libvirt lock management daemon
 
 =head1 SYNOPSIS
 
-B<virtlockd> [ -dv ] [ -f config_file ] [ -p pid_file ]
+B<virtlockd> [ -dvV ] [ -t timeout] [ -f config_file ] [ -p pid_file ]
 
 B<virtlockd> --version
 
@@ -38,6 +38,11 @@ Run as a daemon and write PID file.
 
 Use this configuration file, overriding the default value.
 
+=item B<-t, --timeout> I<SECONDS>
+
+Automatically shutdown after I<SECONDS> have elapsed with
+no active client or lock.
+
 =item B<-p, --pid-file> I<FILE>
 
 Use this name for the PID file, overriding the default value.
-- 
2.5.0

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