qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v1 1/1] io/channel-watch.c: Only select on what


From: Paolo Bonzini
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 13:09:39 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0

On 13/07/2017 12:23, Daniel P. Berrange wrote:
> On Thu, Jul 13, 2017 at 03:15:49AM -0700, Alistair Francis wrote:
>> 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.

This makes sense, and it means the corresponding aio-win32 patch is
wrong too.

WSAEventSelect events are edge-triggered, so they shouldn't be too bad.
In particular, they won't cause a busy wait.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]