From owner-freebsd-stable@FreeBSD.ORG Mon Aug 30 18:46:15 2004 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E060016A4CE for ; Mon, 30 Aug 2004 18:46:15 +0000 (GMT) Received: from outmx006.isp.belgacom.be (outmx006.isp.belgacom.be [195.238.2.99]) by mx1.FreeBSD.org (Postfix) with ESMTP id ECF5643D5E for ; Mon, 30 Aug 2004 18:46:14 +0000 (GMT) (envelope-from tijl@ulyssis.org) Received: from outmx006.isp.belgacom.be (localhost [127.0.0.1]) with ESMTP id i7UIkCPv017946 for ; Mon, 30 Aug 2004 20:46:12 +0200 (envelope-from ) Received: from kalimero.kotnet.org (251-173.240.81.adsl.skynet.be [81.240.173.251])with ESMTP id i7UIk9Ea017918 for ; Mon, 30 Aug 2004 20:46:09 +0200 (envelope-from ) Received: from localhost (localhost [127.0.0.1]) by kalimero.kotnet.org (8.12.11/8.12.11) with SMTP id i7UIjsLf068558 for ; Mon, 30 Aug 2004 20:45:55 +0200 (CEST) (envelope-from tijl@ulyssis.org) Date: Mon, 30 Aug 2004 20:45:53 +0200 From: Tijl Coosemans To: freebsd-stable@freebsd.org Message-Id: <20040830204553.0046ca41.tijl@ulyssis.org> In-Reply-To: <20040829113539.58e09498.tijl@ulyssis.org> References: <20040829113539.58e09498.tijl@ulyssis.org> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; i386-portbld-freebsd4.10) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Mon__30_Aug_2004_20_45_53_+0200_XXKSKcEpDqqjKB=i" Subject: Re: 4-stable termios diff behaviour lc/lc_r X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Aug 2004 18:46:16 -0000 This is a multi-part message in MIME format. --Multipart=_Mon__30_Aug_2004_20_45_53_+0200_XXKSKcEpDqqjKB=i Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Original message on -questions, but this list seems more appropriate. More below. On Sun, 29 Aug 2004 11:35:39 +0200, Tijl Coosemans wrote: > Hi list, > > I think I've found a possible bug in 4-stable, though I'm not that > kind of an expert so I'll leave that decision up to you. > > Attached is a little test program that opens /dev/cuaa0 and tries to > read a couple bytes. > > When compiled using "gcc vtime.c -o vtime" there's no problem. For > example, when you run vtime without anything attached to cuaa0, > it'll wait about 2 seconds and timeout, since VMIN=0 and VTIME=20. > > When compiled using "gcc -pthread vtime.c -o vtime" however, the > read function returns immediately, which as far as I can understand, > is not what it's supposed to do. > > Does anyone know if this intended or not, or how I can get the right > behaviour in a threaded program? I've done some more testing. It appears that when linked with lc_r, VTIME is completely ignored. As explained in termios(4), when VMIN>0, the read call will wait indefinitely for the first byte and then use VTIME as an interbyte timer. When using lc_r however, it'll return immediately after the first couple bytes read, even if that's less than VMIN. The case where VTIME==0 works as it should both with lc and lc_r. I dont have access to a box with -current, so I can't say if the same applies to it. I hope somebody understands this better or could at least give me a few pointers as to where to look in the source code. Thanks, tijl --Multipart=_Mon__30_Aug_2004_20_45_53_+0200_XXKSKcEpDqqjKB=i Content-Type: text/plain; name="vtime.c" Content-Disposition: attachment; filename="vtime.c" Content-Transfer-Encoding: base64 I2luY2x1ZGUgPGZjbnRsLmg+CiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8c3lzL3R5cGVz Lmg+CiNpbmNsdWRlIDx0ZXJtaW9zLmg+CiNpbmNsdWRlIDx1bmlzdGQuaD4KCmV4dGVybiBpbnQg ZXJybm87CgppbnQgbWFpbih2b2lkKSB7CglpbnQgZmQsIGxlbjsKCXN0cnVjdCB0ZXJtaW9zIHRl cm1zZXQ7Cgl1aW50OF90IGRhdGFbMjU2XTsKCglmZCA9IG9wZW4oIi9kZXYvY3VhYTAiLCBPX1JE V1IgfCBPX0ZTWU5DKTsKCXByaW50ZigiJWQgJWRcbiIsIGZkLCBlcnJubyk7CglpZiAoZmQgIT0g LTEpIHsKCQl0Y2dldGF0dHIoZmQsICZ0ZXJtc2V0KTsKCQljZm1ha2VyYXcoJnRlcm1zZXQpOwoJ CWNmc2V0c3BlZWQoJnRlcm1zZXQsIEI5NjAwKTsKCQl0ZXJtc2V0LmNfY2NbVk1JTl0gPSAxOwoJ CXRlcm1zZXQuY19jY1tWVElNRV0gPSAwOwoJCXRjc2V0YXR0cihmZCwgVENTQU5PVywgJnRlcm1z ZXQpOwoKCQlsZW4gPSByZWFkKGZkLCAodm9pZCAqKSBkYXRhLCAzKTsKCQlwcmludGYoIiVkXG4i LCBsZW4pOwoKCQljbG9zZShmZCk7Cgl9CglyZXR1cm4gMDsKfQ== --Multipart=_Mon__30_Aug_2004_20_45_53_+0200_XXKSKcEpDqqjKB=i--