Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Oct 2001 19:20:01 -0700 (PDT)
From:      Bruce Evans <bde@zeta.org.au>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/31255: select with zero timeout returns 0 even when data pending
Message-ID:  <200110140220.f9E2K1b62946@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/31255; it has been noted by GNATS.

From: Bruce Evans <bde@zeta.org.au>
To: <root@do-labs.spb.ru>
Cc: <FreeBSD-gnats-submit@FreeBSD.ORG>
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200110140220.f9E2K1b62946>