delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/03/16/05:35:55

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 559F4387703B
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1584351319;
bh=EYjuVIWE6uH31EZZCybzJvmsnLPQRN/B26B2AaoATWU=;
h=Date:From:To:Subject:References:In-Reply-To:List-Id:
List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
Reply-To:From;
b=m4UW/XNpZFxbd2jTcGTBq6yhp5AcJ4aoLIERqWPBc6fCOp+eo3KgsJwit6hssKcyO
zjC0b/e1pvAO3Qu0sy2IVnx0iuGlCW5NhaloiT6d5R75WOf4TlC9t4VGtPJPC+40Rr
88w2iML8p7M3g9Z1n7HL8dLV8i58OKEme1ERy7xQ=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
Date: Mon, 16 Mar 2020 10:35:14 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Setting termios VMIN > 0 and VTIME > 0 on non blocking file
Message-ID: <20200316093514.GG512788@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <9e4c6428-59de-df07-9e33-44ba95d5497f AT gmail DOT com>
<20200312114041 DOT GJ4042 AT calimero DOT vinschen DOT de>
<365dd437-7553-eb4e-3253-aba3bab74895 AT gmail DOT com>
<20200312144445 DOT GP4042 AT calimero DOT vinschen DOT de>
<20200312150833 DOT GQ4042 AT calimero DOT vinschen DOT de>
<9e56e005-660b-373e-d557-9c8bc97c45ba AT gmail DOT com>
<20200313101247 DOT GD512788 AT calimero DOT vinschen DOT de>
<2156fb6d-cba9-b70e-f8c0-7043ff52ffc3 AT gmail DOT com>
<8e0973e2-9554-3e69-fa88-ed51fad5b191 AT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <8e0973e2-9554-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ZKSS2zK5dgBlLbyvN9bVxfL+PuWk32MzsMSZfBLamkFE5dq0oM9fMHvwZGrN
lFfnTTdzbKrM1iYfFOuTUQqPXFI5sHtFVrA+EqqD5R53pdPzBuqnRQEIzXudB94h82sms03
X-Spam-Status: No, score=-99.0 required=5.0 tests=GOOD_FROM_CORINNA_CYGWIN,
KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,
SPF_NONE autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: Cygwin mailing list <cygwin.cygwin.com>
List-Unsubscribe: <http://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <http://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <http://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Reply-To: cygwin AT cygwin DOT com
Errors-To: cygwin-bounces AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

--===============2993392219239388255==
Content-Type: multipart/signed; micalg=pgp-sha256;
	protocol="application/pgp-signature"; boundary="3Gf/FFewwPeBMqCJ"
Content-Disposition: inline


--3Gf/FFewwPeBMqCJ
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mar 14 11:36, =C3=85ke Rehnman via Cygwin wrote:
> On 2020-03-14 11:23, =C3=85ke Rehnman wrote:
> > Your patch works (for my test case and screen). Question is if we have
> > to consider the case where ulen=3D=3D0 ...

Thanks for testing!

> > > > BTW there is a gremlin in the "else if (ev)" line....
> > > A gremlin?=C2=A0 Would you mind to explain?=C2=A0 Btw., if you find a=
 bug
> > > in the code, we do take patches :) https://cygwin.com/contrib.html
> > If we have an error event in ev it will make a blocking read even if
> > VTIME=3D=3D0.

Ah, yeah, I was aware of that, I just ignored it for now since I'm not
sure what the best way to handle that is.

Two options come to mind, either ignoring these errors entirely, or
returning -1 with errno set to EIO, along the lines of the Linux test
for tty_io_error() at the start of tty_read.

However, I have a sinking feeling that the function needs a rewrite
anyway.

For instance, consider reading in blocking mode, which may result in
running the for loop more than once.  If the first loop successfully
read 4 bytes, and the second loop runs into an error from
ClearCommError, the function will return -1 with errno set, completely
ignoring the fact that 4 bytes have been read already.

It should return 4 in this case, and only the next run of
fhandler_serial::raw_read *might* return -1.

This code really shows its age...


> I forgot, also any CancelIo should be terminated with a blocking
> GetOverlappedResult() see this excellent blog post
> https://devblogs.microsoft.com/oldnewthing/20110202-00/?p=3D11613
>=20
>    // took longer than 1 second - cancel it and give up
>    CancelIo(h);
>    WaitForSingleObject(o.hEvent, INFINITE); // added // Alternatively:
> GetOverlappedResult(h, &o, TRUE);
>    return WAIT_TIMEOUT;

Thanks, fixed in git.


Corinna

--=20
Corinna Vinschen
Cygwin Maintainer

--3Gf/FFewwPeBMqCJ
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl5vSFIACgkQ9TYGna5E
T6AVag//X59BkUQNlPydZuujR2bBO80svjVJ+N4mjGBRffY8CWcc2suuQJqkcBN6
q3AsAkIvKWG8JG572yrEUSyb1X9F74KjuyJqSAE2u7E9F37QYMMGDEzKwPCiM76l
Mqigwv+Kd59H42fCDnf2nAM+3zYhtpjpXlwuB37IiHwbAtE2+hYRA8fh7o9iMPWb
QrF/6hRF91wkRnUyM2BxJeAPleFILVTzJ2gaYUdqbSH1PQDgYugPrQ92nWBar1XB
NjVliJwftdhL6Xxt2V3zcT2up1BLZQqrXwrCVmmqqYcjWHH85r06APCmgd7yX7MO
QXTdT5pGCQHY4ptjzey7stRxgo6Q37JxBiGtL/Z57oSPB33pXlwFRK/ElzFSIRPK
1lgZrY3BbGDwbwR/rhbky0qJEdzjIGeEEu+60SmkG4G3x1e4OezyI2oQbAc5/mZ8
P3LBD91EHz8yy4nZTrgfIJABT7w0w6OnhnEEFVNd5ru1xJuax/AwVHipYVGBTr57
2+I64Tx6LngOvYxcxhCklVe+Q6pzK/Ab4s13rhkmvLmRjd8oEvpw7YTZSEwejxhn
oRK/4qiD0nznP/gIhqRBNYL0K+0K+9GyLXCd/ZGXZ2FFmsxlUUGhr9xCUmbs3ROE
7rBPXAAD0dS7MyNXfqwxF5e1/C2HDMqP2s5aqc9Wcfj3v+f89qo=
=isF4
-----END PGP SIGNATURE-----

--3Gf/FFewwPeBMqCJ--

--===============2993392219239388255==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

--===============2993392219239388255==--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019