This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin hangs up if several keys are typed during outputting a lot of texts.


On Thu, 5 Mar 2015 13:59:01 +0100
Corinna Vinschen <corinna-cygwin@cygwin.com> wrote:

> > One small thing to be improved is here:
> > 
> > +      if (echo_cnt > 0
> > +	  && ReadFile (echo_r, outbuf, MIN (rlen, echo_cnt), &n, NULL))
> > 
> > echo_cnt returned by ::bytes_available() is actually
> > not a number of bytes available in the pipe. This is
> > because ::bytes_available() returns "nleft" instead
> > of "navail" when "nleft" is non-zero.
> > 
> > Therefore, "rlen" should be used here rather than
> > "MIN (rlen, echo_cnt)".
> 
> Thanks, done.  I applied the patch now with two additional changes for
> better error handling.

For the same reason, I propose the following patch.

2015-04-03  Takashi Yano  <takashi.yano@nifty.ne.jp>

	* fhandler_tty.cc (fhandler_pty_slave::read): Change calculation of
	"readlen" not to use "bytes_in_pype" value directly.

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 89cc9e5..daa24eb 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -742,7 +742,7 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
 	  return;
 	}
 
-      readlen = MIN (bytes_in_pipe, MIN (len, sizeof (buf)));
+      readlen = bytes_in_pipe ? MIN (len, sizeof (buf)) : 0;
 
 #if 0
       /* Why on earth is the read length reduced to vmin, even if more bytes


-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

--
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]