This is the mail archive of the
cygwin-cvs@cygwin.com
mailing list for the Cygwin project.
[newlib-cygwin] Be truthful about reporting whether readahead is available
- From: Corinna Vinschen <corinna at sourceware dot org>
- To: cygwin-cvs at sourceware dot org
- Date: 5 Apr 2016 18:44:38 -0000
- Subject: [newlib-cygwin] Be truthful about reporting whether readahead is available
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=03ecfb9280ece68cce33c2f2002877d9a000ef1e
commit 03ecfb9280ece68cce33c2f2002877d9a000ef1e
Author: Johannes Schindelin <johannes.schindelin@gmx.de>
Date: Tue Apr 5 10:52:01 2016 +0200
Be truthful about reporting whether readahead is available
In 7346568 (Make requested console reports work, 2016-03-16), code was
introduced to report the current cursor position. It works by using a
pointer that either points to the next byte in the readahead buffer, or
to a NUL byte if the buffer is depleted, or the pointer is NULL.
These conditions are heeded in the fhandler_console::read() method, but
the condition that the pointer can point at the end of the readahead
buffer was not handled properly in the get_cons_readahead_valid()
method.
This poses a problem e.g. in Git for Windows (which uses a slightly
modified MSYS2 runtime which is in turn a slightly modified Cygwin
runtime) when vim queries the cursor position and immediately goes on to
read console input, erroneously thinking that the readahead buffer is
valid when it is already depleted instead. This condition results in an
apparent freeze that can be helped only by pressing keys repeatedly.
The full Git for Windows bug report is here:
https://github.com/git-for-windows/git/issues/711
Let's just teach the get_cons_readahead_valid() method to handle a
depleted readahead buffer correctly.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Diff:
---
winsup/cygwin/fhandler.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 4610557..bd1a923 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1453,7 +1453,8 @@ private:
bool focus_aware () {return shared_console_info->con.use_focus;}
bool get_cons_readahead_valid ()
{
- return shared_console_info->con.cons_rapoi != NULL;
+ return shared_console_info->con.cons_rapoi != NULL &&
+ *shared_console_info->con.cons_rapoi;
}
select_record *select_read (select_stuff *);