[virt-tools-list] [virt-viewer][PATCH 5/6] events: Don't create glib IO watch for disabled handles

Christophe Fergeau cfergeau at redhat.com
Fri Jul 17 16:38:32 UTC 2015


ACK.

On Fri, Jul 17, 2015 at 04:01:22PM +0200, Fabiano Fidêncio wrote:
> It's possible to create a handle to watch for file events which do not
> watch for any file event. Such a handle can be enabled later with
> gvir_event_handle_update() by setting some conditions to watch for.
> 
> When a handle is disabled after it has been created,
> gvir_event_handle_update() makes sure it removes the corresponding
> gvir_event_handle::source IO watch if any was set.
> gvir_event_handle_add() will always create a gvir_event_handle::source
> IO watch even if the handle is not watching for any events.
> 
> This commit makes consistent by only creating a watch with g_io_add_watch()
> when the caller asked to watch for some events.
> 
> Based on
> http://libvirt.org/git/?p=libvirt-glib.git;a=commit;h=d71c143936a35cd6c3f23ae0cbf7f3215d944051
> 
> Related to: rhbz#1243228
> ---
>  src/virt-viewer-events.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/src/virt-viewer-events.c b/src/virt-viewer-events.c
> index ef2c317..c6442f6 100644
> --- a/src/virt-viewer-events.c
> +++ b/src/virt-viewer-events.c
> @@ -113,10 +113,12 @@ int virt_viewer_events_add_handle(int fd,
>  
>      g_debug("Add handle %d %d %p", data->fd, events, data->opaque);
>  
> -    data->source = g_io_add_watch(data->channel,
> -                                  cond,
> -                                  virt_viewer_events_dispatch_handle,
> -                                  data);
> +    if (events != 0) {
> +        data->source = g_io_add_watch(data->channel,
> +                                      cond,
> +                                      virt_viewer_events_dispatch_handle,
> +                                      data);
> +    }
>  
>      g_ptr_array_add(handles, data);
>  
> -- 
> 2.4.4
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20150717/e45eb618/attachment.sig>


More information about the virt-tools-list mailing list