delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-Original-To: | cygwin AT cygwin DOT com |
Delivered-To: | cygwin AT cygwin DOT com |
Date: | Thu, 12 Mar 2020 16:08:33 +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: | <20200312150833.GQ4042@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> | |
MIME-Version: | 1.0 |
In-Reply-To: | <20200312144445.GP4042@calimero.vinschen.de> |
X-Provags-ID: | V03:K1:3nl2k0X7REWWfRkyoBVVIc3xeNeVHaQdu/MkZ22Dma9V5EKkkoJ |
FF3yv/sYPY6t2hCJm7bv1CQUhwhws80uaG61GAp40DmLEbZN7BL4zla8DJoQWE/98HVSsLG | |
JwGU98gQMLDBwUgbdmYcTUsKRf6+//4CbepG/6f4JjoNPz3VAY8mnKbE8Nsb4Vj0NT11nsR | |
lvrKK+kUyzzaALXZz5k5g== | |
X-UI-Out-Filterresults: | notjunk:1;V03:K0:60F8ho/S8S8=:vdpOj2fM1cI2sV0I+e4JV7 |
v/qzg9QurvxdfdFfo92wcnVZ90YseF2lwWsN0OS/rXCyYMEYjicbDgZqJZK6M82fVivNjyCNR | |
7QWtRBNckozDVIHY0dzCpxb0kW4Emxd1jK0vIriHyXIlafgxzU6aMHZMaYL+6VaVAtggX4AhV | |
y38WhZYV5yfAnUCkeIeXBikkujd5rszNZjebK7hyRJYohE57ilufJV+9uouLEcNiD+t6HHEM+ | |
dw4vaDngM1yxyNOf3w53GENS/IQktbzSHJe3ZKSapLK6LKad2/dTwsMAQHDev5PGimKfKi5hK | |
mGbfh51gRLQWRV6cYCG7H2P7HBKiOBHipD1qbT8HYYbcrtCRXXmm8MJalIVA8lRxnexh6TWle | |
NNK8RQt1kIlZl6h590++M5mlv9YJZLdNIdTNA4NxFDcN6ZFB/B0HPSJRCrABTDpSDeOQFSefk | |
7w90coPxbjIJ+Vtf5C8L3Zkmlicf00+5L7BzKDXnKmY5ncPeTpYsaGVDp0QVWKy9ZPjb65rxb | |
QveKCmL/AtCJ3l8g2Se6/njIkjxFPs1UdANkyNJZhYl+tLl0W72hMHWpkAz3dDdsVJ1gEQ8to | |
YhGE/L1YialjyU/8Z46YIE8ysHgjGsG8kdNBLTEE7dOMx4ooD4DlLJckFi8I7W2VjzgUfF/cY | |
sOTWrN92eemEq+lx57hIZO9jElfTXT28iST/BBmJpvVNjjaEhCLF0kS/y9UFmqjaqOEeIrtov | |
YAp86iRcmvy4ckmWDKVYkSEaZWaeL5ClbhfqgWWx+d2+3jcKY/GTPmOnLZQauMlwqQ/XbK2xV | |
ChmGqPS5/C2Lx2iWi6a83btL4mDj0EcAdjNvxF5y+O+uEHmgbVq7qa2+sR0nL2kd+3pY77U | |
X-Spam-Status: | No, score=-124.4 required=5.0 tests=BAYES_00, GARBLED_BODY, |
GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, GOOD_FROM_CORINNA_CYGWIN, | |
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> |
--===============0385289546164522454== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="worL9B4ITIAQZ1FS" Content-Disposition: inline --worL9B4ITIAQZ1FS Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mar 12 15:44, Corinna Vinschen wrote: > On Mar 12 15:20, =C3=85ke Rehnman via Cygwin wrote: > > I think the problem is if the number of bytes requested are more than w= hat >=20 > To clarify: number of bytes =3D=3D VMIN? >=20 > > is in the buffer it is going to overlap the read function (because of V= TIME) > > and immediately after that CancelIO is called. Contrary to what is ment= ioned > > in the source code I think CancelIO is actually discarding data... >=20 > So far we didn't have that experience. CancelIO is usually safe > in this regard. >=20 > > =C2=A0 /* Use CancelIo rather than PurgeComm (PURGE_RXABORT) since > > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 PurgeComm apparently discar= ds in-flight bytes while CancelIo > > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 only stops the overlapped I= O routine. */ > >=20 > >=20 > > My suggestion is the following patch: > >=20 > > diff --git a/winsup/cygwin/fhandler_serial.cc > > b/winsup/cygwin/fhandler_serial.cc > > index 69e5768f6..afa8871bf 100644 > > --- a/winsup/cygwin/fhandler_serial.cc > > +++ b/winsup/cygwin/fhandler_serial.cc > > @@ -898,7 +898,11 @@ fhandler_serial::tcsetattr (int action, const stru= ct > > termios *t) > > =C2=A0=C2=A0 { > > =C2=A0=C2=A0=C2=A0=C2=A0 memset (&to, 0, sizeof (to)); > >=20 > > -=C2=A0=C2=A0=C2=A0 if ((vmin_ > 0) && (vtime_ =3D=3D 0)) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (is_nonblocking()) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 to.ReadIntervalTimeout =3D MAXDWORD; > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > > +=C2=A0=C2=A0=C2=A0 else if ((vmin_ > 0) && (vtime_ =3D=3D 0)) >=20 > What if you switch to !O_NONBLOCK after calling tcsetattr? The > setting of ReadIntervalTimeout would be lost then. >=20 > Either we have to repeat calling SetCommTimeouts every time > we switch mode, or we have to do the above setting temporary > every time we call ReadFile in non blocking mode. What about this: diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_seri= al.cc --- a/winsup/cygwin/fhandler_serial.cc +++ b/winsup/cygwin/fhandler_serial.cc @@ -68,6 +68,16 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen) goto err; else if (ev) termios_printf ("error detected %x", ev); + else if (is_nonblocking ()) + { + if (!st.cbInQue) + { + tot =3D -1; + set_errno (EAGAIN); + goto out; + } + inq =3D st.cbInQue; + } else if (st.cbInQue && !vtime_) inq =3D st.cbInQue; else if (!is_nonblocking () && !overlapped_armed) Corinna --=20 Corinna Vinschen Cygwin Maintainer --worL9B4ITIAQZ1FS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl5qUHEACgkQ9TYGna5E T6DXeBAAj9Fry9Zf3MXUtyGGy8v54eyrH2iYq3Z1WxauE2Nzz00wVj3wrEDdmnC1 zjE+WI/x/YuEvI5nZVhcgVMzR4srhqi0QMWwV30ATN8cFTclWAzGy8L0d4PaHTcJ e5xP1c6Hn3DyzgOjmBy8Vhm0z+GXiTfPp5dk96ShC4ycrUjbbu6AFcs/7SF+BH9v qaFHQKrxorErp0GdQF2OU/BZHPC7tUrAF0SMvU/arTY1knFsNFG4E7ublMttVfwU Fp1UEfI/u2+yMNQh4GjOc87qusLzPxsbXuTqbWGhQm2q8cHKC3X7suxxNkAmLrXb 2oVsoqqhImv0Ze/frZOP70Q8TQlTOwwwa9vgqJrZvUyec1gRlaM7HFKmxVy0scxt +OuQc8GGqfZOgFKeGCoIytH5Uv2N/B3/PXR95oABwhoECs1z8ThHZ1jI9EQe/HMn GXZe5dwZOISJOkV1IweHy45P4kOML1SR9bGpaboiszY/M+cTld17V+Lyh1wMWA6N fBIesLeNld6Col/D6FEgaciueVQ58Z/S+anKM16EvN88zt1Is2xhlDtkvsa5A3Q3 ip8vSnXfbgXOndr/dO4vOEt3CR+heX+imAqp1O4Q1iKsa1KvoX1DWAh1m71TMZO7 IQjhQnoW84zqSinQeuJCAun4hFk8hAscPLddshfq7UqVGsdAByY= =Nkc/ -----END PGP SIGNATURE----- --worL9B4ITIAQZ1FS-- --===============0385289546164522454== 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 --===============0385289546164522454==--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |