All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Alistair Francis <alistair.francis@xilinx.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, stefanha@redhat.com,
	alistair23@gmail.com
Subject: Re: [Qemu-devel] [PATCH v1 1/1] io/channel-watch.c: Only select on what we are actually waiting for
Date: Thu, 13 Jul 2017 11:23:59 +0100	[thread overview]
Message-ID: <20170713102359.GH4011@redhat.com> (raw)
In-Reply-To: <468425bd8090e3a9fd7fc791db42e24d6c75315c.1499940552.git.alistair.francis@xilinx.com>

On Thu, Jul 13, 2017 at 03:15:49AM -0700, Alistair Francis wrote:
> When calling WAEventSelect() only wait on events as specified by the
> condition variable. This requires that the condition variable is set
> correctly for the specific events that we need to wait for.

Can you describe the actual problem / buggy behaviour you were seeing
with the current code.

> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
> ---
> 
>  io/channel-watch.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/io/channel-watch.c b/io/channel-watch.c
> index 8640d1c464..d80722f496 100644
> --- a/io/channel-watch.c
> +++ b/io/channel-watch.c
> @@ -286,9 +286,21 @@ GSource *qio_channel_create_socket_watch(QIOChannel *ioc,
>      QIOChannelSocketSource *ssource;
>  
>  #ifdef WIN32
> -    WSAEventSelect(socket, ioc->event,
> -                   FD_READ | FD_ACCEPT | FD_CLOSE |
> -                   FD_CONNECT | FD_WRITE | FD_OOB);
> +    long bitmask = 0;
> +
> +    if (condition & (G_IO_IN | G_IO_PRI)) {
> +        bitmask |= FD_READ | FD_ACCEPT;
> +    }
> +
> +    if (condition & G_IO_HUP) {
> +        bitmask |= FD_CLOSE;
> +    }
> +
> +    if (condition & G_IO_OUT) {
> +        bitmask |= FD_WRITE | FD_CONNECT;
> +    }
> +
> +    WSAEventSelect(socket, ioc->event, bitmask);
>  #endif

I think the problem with doing this is that WSAEventSelect is a global
setting that applies to the socket handle. If you use qio_channel_create_watch
twice on the same socket with different events, the second watch will break
the first watch by potentially discarding events that it requested.


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

  reply	other threads:[~2017-07-13 10:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-13 10:15 [Qemu-devel] [PATCH v1 1/1] io/channel-watch.c: Only select on what we are actually waiting for Alistair Francis
2017-07-13 10:23 ` Daniel P. Berrange [this message]
2017-07-13 11:09   ` Paolo Bonzini
2017-07-13 12:38     ` Alistair Francis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170713102359.GH4011@redhat.com \
    --to=berrange@redhat.com \
    --cc=alistair.francis@xilinx.com \
    --cc=alistair23@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.