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: <4C7A62FD.10506@dronecode.org.uk> Date: Sun, 29 Aug 2010 14:39:09 +0100 From: Jon TURNEY 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: /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> <4C5DD910 DOT 9050809 AT dronecode DOT org DOT uk> In-Reply-To: Content-Type: multipart/mixed; boundary="------------030309060805010508040909" Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --------------030309060805010508040909 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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. --------------030309060805010508040909 Content-Type: text/plain; name="dev-windows-select-test.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="dev-windows-select-test.c" CiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8ZmNudGwuaD4KI2luY2x1 ZGUgPHN5cy9zZWxlY3QuaD4KI2luY2x1ZGUgPGVycm5vLmg+CiNpbmNsdWRl IDx3aW5kb3dzLmg+CgovLyBnY2MgLW8gZGV2LXdpbmRvd3Mtc2VsZWN0LXRl c3QuZXhlIGRldi13aW5kb3dzLXNlbGVjdC10ZXN0LmMgLVdhbGwgLW13aW5k b3dzCgppbnQgbWFpbihpbnQgYXJnYywgY2hhciAqYXJndltdKQp7CiAgaW50 IGZkID0gb3BlbigiL2Rldi93aW5kb3dzIiwgT19SRE9OTFkpOwoKICBpZiAo UG9zdE1lc3NhZ2UoTlVMTCwgV01fVVNFUiwgMCwgMCkgIT0gMCkKICAgIHBy aW50ZigiUG9zdE1lc3NhZ2Ugc3VjY2VlZGVkXG4iKTsKICBlbHNlCiAgICBw cmludGYoIlBvc3RNZXNzYWdlIGZhaWxlZFxuIik7CgogIGlmIChhcmdjIDw9 IDEpCiAgICB7CiAgICAgIE1TRyBtc2c7CiAgICAgIGlmIChQZWVrTWVzc2Fn ZSgmbXNnLCBOVUxMLCAwLCAwLCBQTV9OT1JFTU9WRSkpCiAgICAgICAgcHJp bnRmKCJQZWVrTWVzc2FnZSByZXBvcnRzIGEgbWVzc2FnZSBhdmFpbGFibGVc biIpOwogICAgfQoKICBzdHJ1Y3QgdGltZXZhbCB0aW1lb3V0OwogIHRpbWVv dXQudHZfc2VjID0gNTsKICB0aW1lb3V0LnR2X3VzZWMgPSAwOwoKICBmZF9z ZXQgcmVhZGZkczsKICBGRF9aRVJPKCZyZWFkZmRzKTsKICBGRF9TRVQoZmQs ICZyZWFkZmRzKTsKCiAgaW50IHJjID0gc2VsZWN0KGZkKzEsICZyZWFkZmRz LCBOVUxMLCBOVUxMLCAmdGltZW91dCk7CiAgcHJpbnRmKCJzZWxlY3QgcmV0 dXJuZWQgJWQgJXNcbiIsIHJjLCBzdHJlcnJvcihlcnJubykpOwoKICByZXR1 cm4gMDsKfQo= --------------030309060805010508040909 Content-Type: text/plain; charset=us-ascii -- 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 --------------030309060805010508040909--