9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] APE libap.a (?)
@ 2004-04-02  9:32 lucio
  0 siblings, 0 replies; only message in thread
From: lucio @ 2004-04-02  9:32 UTC (permalink / raw)
  To: 9fans

The following code in /sys/src/ape/lib/ap/plan9/_buf.c strikes me at
first glance as being wrong:

	/* make sure all requested rfds and efds are buffered */
	if(nfds >= OPEN_MAX)
		nfds = OPEN_MAX-1;
	for(i = 0; i<= nfds; i++)
		if((rfds && FD_ISSET(i, rfds)) || (efds && FD_ISSET(i, efds))){
			f = &_fdinfo[i];
			if(!(f->flags&FD_BUFFERED))
				if(_startbuf(i) != 0) {
					return -1;
				}

The "nfsd" limit in the for() heading is unlikely to need testing less
than _or_equal_to_ when one starts counting from zero.  Then again,
the limiting code preceding the for() heading may be wrong too and
might be the cause of the confusion.

++L

PS: In fact, the NetBSD man page is quite explicit:

     select() examines the I/O descriptor sets whose addresses are passed in
     readfds, writefds, and exceptfds to see if some of their descriptors are
     ready for reading, are ready for writing, or have an exceptional condi-
     tion pending, respectively.  The first nfds descriptors are checked in
     each set; i.e., the descriptors from 0 through nfds-1 in the descriptor
                                     ^^^^^^^^^^^^^^^^^^^^^
     sets are examined.  On return, select() replaces the given descriptor
     sets with subsets consisting of those descriptors that are ready for the
     requested operation.  select() returns the total number of ready descrip-
     tors in all the sets.



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-04-02  9:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-02  9:32 [9fans] APE libap.a (?) lucio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).