提交 876211ef 编写于 作者: M Michal Privoznik

leaseshelper: Wait to acquire PID file

On a DHCP transaction, dnsmasq runs our leases helper which
updates corresponding JSON files. While one dnsmasq won't run the
leaseshelper in parallel, two dnsmasqs (from two distinct
networks) might. To avoid corrupting JSON file, the leaseshelper
acquires PID file first. Well, the way it's acquiring it is not
ideal - it calls virPidFileAcquirePath(wait = false); which
means, that either it acquires the PID file instantly or returns
an error and does not touch the JSON at all. This in turn means
that there might be a leases record missing. With wait = true,
this won't happen.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1840307Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 5331c480
......@@ -160,7 +160,7 @@ main(int argc, char **argv)
pid_file = g_strdup(RUNSTATEDIR "/leaseshelper.pid");
/* Try to claim the pidfile, exiting if we can't */
if ((pid_file_fd = virPidFileAcquirePath(pid_file, false, getpid())) < 0)
if ((pid_file_fd = virPidFileAcquirePath(pid_file, true, getpid())) < 0)
goto cleanup;
/* Since interfaces can be hot plugged, we need to make sure that the
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册