delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/08/30/08:05:15

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW
X-Spam-Check-By: sourceware.org
Message-ID: <4C7B9E4B.2060800@dronecode.org.uk>
Date: Mon, 30 Aug 2010 13:04:27 +0100
From: Jon TURNEY <jon DOT turney AT dronecode DOT org DOT uk>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2
MIME-Version: 1.0
To: cygwin-xfree AT cygwin DOT com, cygwin AT cygwin DOT com
Subject: Re: /dev/windows and select() [was Re: Slow response to keypresses in xorg-server-1.8.0-1]
References: <4BDC3161 DOT 9070101 AT cornell DOT edu> <4BDDE5F1 DOT 9080204 AT cornell DOT edu> <4C2B8171 DOT 5020409 AT dronecode DOT org DOT uk> <4C5B08AE DOT 4080902 AT pobox DOT com> <AANLkTin9mOFFkk21dYf+CT2uMXr=x5bnaNsTkH0w0cka AT mail DOT gmail DOT com> <4C5DD910 DOT 9050809 AT dronecode DOT org DOT uk> <AANLkTin6e74L1_Z7KzoOVmynQ+eW6a8tkTK_A21-mpg+@mail.gmail.com> <4C7A62FD DOT 10506 AT dronecode DOT org DOT uk> <20100830112313 DOT GN6726 AT calimero DOT vinschen DOT de>
In-Reply-To: <20100830112313.GN6726@calimero.vinschen.de>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 30/08/2010 12:23, Corinna Vinschen wrote:
> On Aug 29 14:39, Jon TURNEY wrote:
>> On 08/08/2010 12:04, Andy Koppe wrote:
>>> On 7 August 2010 23:07, Jon TURNEY wrote:
>>>> Hmmm, looking again at the implementation of select(), I don't immediately
>>>> see that when waiting on /dev/windows, it checks that the message queue has
>>>> old messages on it before waiting.  The MSDN documentation for
>>>> MsgWaitForMultipleObjects() seems to says that messages which had arrived
>>>> before the last PeekMessage() etc. aren't considered new and so don't end
>>>> the wait?
>>>
>>> I think you're right, a call to PeekMessage is needed for proper
>>> select() semantics: it shouldn't block if data is available for
>>> reading.
>>
>> Attached is a small test-case which seems to demonstrate this problem.
>>
>> Run ./dev-windows-select-test and observe select() blocks for the
>> full timeout, despite the fact that the /dev/windows fd is ready for
>> reading (and it reported as such as the end of the timeout)
>>
>> If you run './dev-windows-select-test -skip' to skip the
>> PeekMessage(), select() returns immediately, indicating the
>> /dev/windows fd is ready for reading.
>
> Again, thanks for the testcase.  I applied a patch to Cygwin which
> should make select on /dev/windows fully functional.
>
> The blessed solution is to replace the call to MsgWaitForMultipleObjects
> with a call to MsgWaitForMultipleObjectsEx with the MWMO_INPUTAVAILABLE
> flag set.  This flag is defined to do exactly what we need.
>
> The only downside is that this flag does not exist on NT4 and its usage
> results in an "invalid argument" error.  So, for NT4, I added the
> workaround I described in my yesterday's soliloquy.
>
> I'm planning to release Cygwin 1.7.7 tomorrow at the latest, so please
> give it a test as soon as possible.  Here's a binary DLL for testing
> (build w/o optimization, so it's probably a bit slow):
>
>    http://cygwin.de/cygwin-177/new-cygwin1.dll.bz2
>    (md5sum: 7e07fd9eafd021697a0861c1ae4fa94e)

Thanks Corinna :-)

I tried that cygwin DLL with my test case, and with an X server with what I 
now realize is the workaround I'd applied reverted [1] and it seems to work fine.

[1] 
http://cgit.freedesktop.org/~yselkowitz/xserver/commit/?h=cygwin-release-1.8&id=6da3190eacae2c2b021060f8fd9427816ac06f21

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019