Re: [PATCH]util: Refresh virHook before checking its existence

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

 



On Wed, Sep 25, 2013 at 03:48:16PM +0800, Chen Hanxiao wrote:
> From: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx>
> 
> We refresh the status of hook scripts
> only when start/stop libvirt, or reload its configuration.
> But the status of hooks scripts may be changed.
> We need to refresh its status before checking its existence.
> 
> Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx>
> ---
>  src/util/virhook.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/src/util/virhook.c b/src/util/virhook.c
> index 159efdb..5500f62 100644
> --- a/src/util/virhook.c
> +++ b/src/util/virhook.c
> @@ -170,11 +170,15 @@ virHookPresent(int driver) {
>      if ((driver < VIR_HOOK_DRIVER_DAEMON) ||
>          (driver >= VIR_HOOK_DRIVER_LAST))
>          return 0;
> -    if (virHooksFound == -1)
> -        return 0;
> +    if (virHookInitialize() > 0) {
> +        if (virHooksFound == -1)
> +            return 0;
>  
> -    if ((virHooksFound & (1 << driver)) == 0)
> +        if ((virHooksFound & (1 << driver)) == 0)
> +            return 0;
> +    } else {
>          return 0;
> +    }
>      return 1;
>  }

Doing this is not thread safe. This can be called from multiple threads
at once.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

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