]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virtlockd: fix misc memory leaks and other bugs
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 24 Nov 2015 13:16:23 +0000 (13:16 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 26 Nov 2015 14:30:26 +0000 (14:30 +0000)
Fix memory leaks, failure to restore umask and missing man
page docs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/locking/lock_daemon.c
src/locking/lock_driver_lockd.c
src/locking/virtlockd.pod.in

index 3dc47c19c8da5a1a040024963a5e1c14039676ee..a5a40fef5a205f889b2a1067f7da3efd8a3dd0da 100644 (file)
@@ -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);
index c974d60da7fb35eb8a7b6dc51931689eced8b1c4..5b89ca142b0b6bd6b67bebde11824050c3bd1ed4 100644 (file)
@@ -166,6 +166,7 @@ static char *virLockManagerLockDaemonPath(bool privileged)
             return NULL;
         }
 
+        VIR_FREE(rundir);
     }
     return path;
 }
index 99612aa537b0380be168f85e19fa353aa7601306..661473ccc9668a32c1fcee328ae00ea2077fd3d7 100644 (file)
@@ -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.