From owner-freebsd-bugs Sat Oct 13 19:20: 6 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id D0A3037B403 for ; Sat, 13 Oct 2001 19:20:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f9E2K1b62946; Sat, 13 Oct 2001 19:20:01 -0700 (PDT) (envelope-from gnats) Date: Sat, 13 Oct 2001 19:20:01 -0700 (PDT) Message-Id: <200110140220.f9E2K1b62946@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Bruce Evans Subject: Re: kern/31255: select with zero timeout returns 0 even when data pending Reply-To: Bruce Evans Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR kern/31255; it has been noted by GNATS. From: Bruce Evans To: Cc: Subject: Re: kern/31255: select with zero timeout returns 0 even when data pending Date: Sun, 14 Oct 2001 12:09:41 +1000 (EST) On 13 Oct 2001 root@do-labs.spb.ru wrote: > >Description: > struct timeval tv = { 0,0 }; > rc = select(...,&tv); > > This code will always return zero even if data is pending > one any descriptor or any descriptor is ready to write. > This is because check for timed out performed before > asking kernel about descriptor state. I can't see this. The descriptors are checked before the timeout. The timeout is just copyin()'ed and (bogusly) validated early, so select() may return an error for certain problems with the timeout even when there is a ready descriptor so there is no need to use the timeout. > Single Unix Spec do not states exactly that zero timeout shall > lead to immediate return with correct descriptor number as result, > but it looks like it is supposed to be as such. POSIX.1-200x-draft7 seems to be exact enough. It says that if none of the descriptors are ready, then select() shall block until one becomes ready or the timeout expires, etc. It doesn't say anything about using the timeout if a descriptor is ready. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message