Re: [PATCH 2/3] leaseshelper: Wait to acquire PID file

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

 



On Mon, Jun 15, 2020 at 01:32:35PM +0200, Michal Privoznik wrote:
> 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=1840307
> 
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/network/leaseshelper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c
> index 02759f2314..c4258cae4e 100644
> --- a/src/network/leaseshelper.c
> +++ b/src/network/leaseshelper.c
> @@ -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

Reviewed-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




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

  Powered by Linux