From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) by sourceware.org (Postfix) with ESMTPS id BF5AE3861C56 for ; Mon, 16 Mar 2020 09:35:16 +0000 (GMT) Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mv2pC-1jVRYo3wWm-00r0T4 for ; Mon, 16 Mar 2020 10:35:14 +0100 Received: by calimero.vinschen.de (Postfix, from userid 500) id 6A67AA806FE; Mon, 16 Mar 2020 10:35:14 +0100 (CET) Date: Mon, 16 Mar 2020 10:35:14 +0100 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Setting termios VMIN > 0 and VTIME > 0 on non blocking file Message-ID: <20200316093514.GG512788@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <9e4c6428-59de-df07-9e33-44ba95d5497f@gmail.com> <20200312114041.GJ4042@calimero.vinschen.de> <365dd437-7553-eb4e-3253-aba3bab74895@gmail.com> <20200312144445.GP4042@calimero.vinschen.de> <20200312150833.GQ4042@calimero.vinschen.de> <9e56e005-660b-373e-d557-9c8bc97c45ba@gmail.com> <20200313101247.GD512788@calimero.vinschen.de> <2156fb6d-cba9-b70e-f8c0-7043ff52ffc3@gmail.com> <8e0973e2-9554-3e69-fa88-ed51fad5b191@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="3Gf/FFewwPeBMqCJ" Content-Disposition: inline In-Reply-To: <8e0973e2-9554-3e69-fa88-ed51fad5b191@gmail.com> X-Provags-ID: V03:K1:guWyCnOVPN1GBWUoGwvsQOdR8PaW5j238JeQIY5JvPSBCuClQvp 0NZ3VOkV7GLHCs8wQZ0RpThgSBKiXr2YEBA887XPHTYGFSlihGO/DBS4GcBoB1y2hgZqtqw IKkkaYuSlWI1WUkpKTEAE1jSKIvG5kusxTsnQCGrN41khjiSURcOZwPDjMfMBczLmGaQLIr s1gW//X04aXj9s/OXaI7g== X-UI-Out-Filterresults: notjunk:1;V03:K0:sSJLOiOLUi8=:61hzqvKTSvSc57X9WNAMEF yFrk4wZeCwZ5EAHWHgXvq38os9xtlIeVGLHhhZg/hNJi7kJHJaK6OYZh3G/p9ZbBls3FaA1E/ 1MT+bgZO0foUN7eagCLgdaNdFYisO7z9/Cnm6SGTfS4Lx5c96vpXL0wTrrON+Usb4J7Zqr/EY zVw7pfOknAJtKpv3R43R9KbHS7OEcEvMiFdvuucW+hqBEe6wuaRt/yWjF+4Mvin9T8PhekfVa ZERg8INV60aq9pf2NoEOl76ueh908j34nm1LJIp8YFL1SJVlqNsAtMhijx8WMYl3Htoc5G//h HhgNI9vxyQ3TCDBoJYPXfTIpiIOGKQFk5JH50nnf0lf5X+RHt1p68jZT5dykZ6ZVbWdSl8Cz9 k+/TR1IWAjzXQzqptmLHUoUu2KPs2YnKEfMt6mCRxfg1MYzsUmYtTbDRI/JsWEgu4Tm8hKalV GjjEvOYHFRDVMsh3Jd66hePmN7G9Z0t4ETCfgjILLT3IQza5yA2dIoPvsf1us0yM1c2W4mI+l XjkfSGZj50Kr6QEOi+xbkEOkqv9dAhEXiqZkB1gcHLjGDH9gQbUzah9/gV9vIYklr/M0hDply C3uHocz4OSrMQpa2pOKxDtrBEMeNvCPawh3CvLfD5swSSab5v5kfNVxE9jYAj/A4OR3hELDd4 auIlNokp6b3QvTkaPDphali4CYbnSIDr1AGr0DeLKp8cGE29JLOXCXhHjvr9a5TX3yf4fKm74 QZxazCzwlHQtNZKSS2zK5dgBlLbyvN9bVxfL+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@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Mar 2020 09:35:18 -0000 --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--