X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=CXkQr5R7fyRdihYt518LpB19fM5Ew5a7EAmC1UxaLwa PKoQeEopSbKNjlTdAEya4EhgarviFAsN7Ya9Jp65KJOqFEb9Hx/AHckttUsMahBY NcSAA/6P7/TfZ+Qy3oOlmZpSuxnMHwENh568N6+KpO7EAvN9riLGK40erXmddWrA = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=f6V5k9EIqtPMaUh/LT8qirgPZ08=; b=B3Hc7kekRRSjb7Mhc rjOawNpECmalY99GCvTvt/oy8iadrkXIXDzs9bKzWzWDW6nPAOFAXV8p4OgpmLuZ sF3OZfYgTjscuEH4BypZxTzIlpp0xbfiT8ZdK7aTIqObXgE01f5IT7OJT1zlBITh 8+TjNkqhBsLrHEEhc2Ck3ERnnw= 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 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 X-Nifty-SrcIP: [121.93.68.199] Date: Fri, 3 Apr 2015 13:07:35 +0900 From: Takashi Yano To: cygwin AT cygwin DOT 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 DOT 0e4cfdb3a26bfac361b538e2 AT nifty DOT ne DOT jp> <20150228140251 DOT GA11124 AT calimero DOT vinschen DOT de> <20150302204502 DOT 39b3e03ad5084b0b5add5d10 AT nifty DOT ne DOT jp> <20150302144426 DOT GK3213 AT calimero DOT vinschen DOT de> <20150304203407 DOT 14008531b0fb63ad5c19a33f AT nifty DOT ne DOT jp> <20150304121952 DOT GL3213 AT calimero DOT vinschen DOT de> <20150304181857 DOT GM3213 AT calimero DOT vinschen DOT de> <20150305202456 DOT 9ac4815a9d590145e15f7ae2 AT nifty DOT ne DOT jp> <20150305125901 DOT GX3213 AT calimero DOT vinschen DOT de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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