From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125375 invoked by alias); 3 Apr 2015 04:07:54 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 125367 invoked by uid 89); 3 Apr 2015 04:07:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: conuserg007-v.nifty.com Received: from conuserg007.nifty.com (HELO conuserg007-v.nifty.com) (202.248.44.33) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (DES-CBC3-SHA encrypted) ESMTPS; Fri, 03 Apr 2015 04:07:52 +0000 Received: from Express5800-S70 (ntsitm305199.sitm.nt.ftth.ppp.infoweb.ne.jp [121.93.68.199]) (authenticated) by conuserg007-v.nifty.com with ESMTP id t3347dQB014410 for ; Fri, 3 Apr 2015 13:07:40 +0900 X-Nifty-SrcIP: [121.93.68.199] Date: Fri, 03 Apr 2015 04:07:00 -0000 From: Takashi Yano To: cygwin@cygwin.com Subject: Re: Cygwin hangs up if several keys are typed during outputting a lot of texts. Message-Id: <20150403130735.d04e41875f7defd0e6c2d8d0@nifty.ne.jp> In-Reply-To: <20150305125901.GX3213@calimero.vinschen.de> References: <20150228144019.0e4cfdb3a26bfac361b538e2@nifty.ne.jp> <20150228140251.GA11124@calimero.vinschen.de> <20150302204502.39b3e03ad5084b0b5add5d10@nifty.ne.jp> <20150302144426.GK3213@calimero.vinschen.de> <20150304203407.14008531b0fb63ad5c19a33f@nifty.ne.jp> <20150304121952.GL3213@calimero.vinschen.de> <20150304181857.GM3213@calimero.vinschen.de> <20150305202456.9ac4815a9d590145e15f7ae2@nifty.ne.jp> <20150305125901.GX3213@calimero.vinschen.de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00061.txt.bz2 On Thu, 5 Mar 2015 13:59:01 +0100 Corinna Vinschen 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 * 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 -- 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