提交 c32d977e 编写于 作者: D Daniel P. Berrange

virtlockd: fix misc memory leaks and other bugs

Fix memory leaks, failure to restore umask and missing man
page docs.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 df34363d
...@@ -118,6 +118,7 @@ virLockDaemonFree(virLockDaemonPtr lockd) ...@@ -118,6 +118,7 @@ virLockDaemonFree(virLockDaemonPtr lockd)
if (!lockd) if (!lockd)
return; return;
virMutexDestroy(&lockd->lock);
virObjectUnref(lockd->dmn); virObjectUnref(lockd->dmn);
virHashFree(lockd->lockspaces); virHashFree(lockd->lockspaces);
virLockSpaceFree(lockd->defaultLockspace); virLockSpaceFree(lockd->defaultLockspace);
...@@ -410,6 +411,7 @@ virLockDaemonUnixSocketPaths(bool privileged, ...@@ -410,6 +411,7 @@ virLockDaemonUnixSocketPaths(bool privileged,
old_umask = umask(077); old_umask = umask(077);
if (virFileMakePath(rundir) < 0) { if (virFileMakePath(rundir) < 0) {
VIR_FREE(rundir);
umask(old_umask); umask(old_umask);
goto error; goto error;
} }
...@@ -516,6 +518,7 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr config, ...@@ -516,6 +518,7 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr config,
old_umask = umask(077); old_umask = umask(077);
if (virFileMakePath(logdir) < 0) { if (virFileMakePath(logdir) < 0) {
VIR_FREE(logdir);
umask(old_umask); umask(old_umask);
goto error; goto error;
} }
...@@ -1187,7 +1190,7 @@ int main(int argc, char **argv) { ...@@ -1187,7 +1190,7 @@ int main(int argc, char **argv) {
int c; int c;
char *tmp; 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) if (c == -1)
break; break;
...@@ -1321,6 +1324,7 @@ int main(int argc, char **argv) { ...@@ -1321,6 +1324,7 @@ int main(int argc, char **argv) {
VIR_ERROR(_("unable to create rundir %s: %s"), run_dir, VIR_ERROR(_("unable to create rundir %s: %s"), run_dir,
virStrerror(errno, ebuf, sizeof(ebuf))); virStrerror(errno, ebuf, sizeof(ebuf)));
ret = VIR_LOCK_DAEMON_ERR_RUNDIR; ret = VIR_LOCK_DAEMON_ERR_RUNDIR;
umask(old_umask);
goto cleanup; goto cleanup;
} }
umask(old_umask); umask(old_umask);
......
...@@ -166,6 +166,7 @@ static char *virLockManagerLockDaemonPath(bool privileged) ...@@ -166,6 +166,7 @@ static char *virLockManagerLockDaemonPath(bool privileged)
return NULL; return NULL;
} }
VIR_FREE(rundir);
} }
return path; return path;
} }
......
...@@ -4,7 +4,7 @@ virtlockd - libvirt lock management daemon ...@@ -4,7 +4,7 @@ virtlockd - libvirt lock management daemon
=head1 SYNOPSIS =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 B<virtlockd> --version
...@@ -38,6 +38,11 @@ Run as a daemon and write PID file. ...@@ -38,6 +38,11 @@ Run as a daemon and write PID file.
Use this configuration file, overriding the default value. 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> =item B<-p, --pid-file> I<FILE>
Use this name for the PID file, overriding the default value. Use this name for the PID file, overriding the default value.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册