X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Sun, 29 Aug 2010 16:41:50 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com, cygwin-xfree AT cygwin DOT com Subject: Re: /dev/windows and select() [was Re: Slow response to keypresses in xorg-server-1.8.0-1] Message-ID: <20100829144150.GI6726@calimero.vinschen.de> Mail-Followup-To: cygwin AT cygwin DOT com, cygwin-xfree AT cygwin DOT com 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> <4C7A62FD DOT 10506 AT dronecode DOT org DOT uk> <20100829141716 DOT GG6726 AT calimero DOT vinschen DOT de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20100829141716.GG6726@calimero.vinschen.de> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: 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 On Aug 29 16:17, 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? > > >[...] > > Thanks for the testcase. I examined this and I think I have a > workaround. MSDN states that there's a flag QS_ALLPOSTMESSAGE for > MsgWaitForMultipleObjects, which is not cleared by PeekMessage, if the > wMsgFilterMin and wMsgFilterMax arguments are not both 0. So, what I > did was to add the QS_ALLPOSTMESSAGE flag to the > MsgWaitForMultipleObjects call in select.cc, and to change the > PeekMessage call in select.cc:peek_windows() from > > PeekMessage (&m, (HWND) h, 0, 0, PM_NOREMOVE) > > to > > PeekMessage (&m, (HWND) h, 1, UINT_MAX, PM_NOREMOVE) > > Same in your above test application. This appears to do the trick. > However, I'm not exactly sure if that's a valid fix. Patch below. Hmm, this ignores the potential WM_NULL message, afaics. For some reason, using PeekMessage (&m, (HWND) h, 0, UINT_MAX, PM_NOREMOVE) results in MsgWaitForMultipleObjects hanging, too. OTOH, using PeekMessage (&m, (HWND) h, 0, 16, PM_NOREMOVE) && PeekMessage (&m, (HWND) h, 17, UINT_MAX, PM_NOREMOVE) does not. Go figure. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- 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