🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sun
Article #11698

Re: "select" (was "Re. Shared libraries linker error")

#11698
From: Guy Harris
Date: Thu, 23 Mar 1989 21:49
33 lines
2243 bytes
>In my experience, this assertion that using fd_sets will solve you
>problems in the case of binary (cf source) compatability is incorrect.

In my original posting, I described "improper" usage of "select" as:

	pass(ing) in pointers to "int"s rather than "fd_set"s, but pass(ing)
	the result of "getdtablesize()" as the first argument under the
	assumption that it will always return a number less than or equal
	to the number of bits in an "int"

and also said:

	...it (is) a bad idea to use "getdtablesize" - or, at least, to
	use it without cutting its value off at 32 - because the system
	might be changed to support more than (# of bits per "int") file
	descriptors...

which was not all meant to "assert that using fd_sets will solve your
problems in the case of binary compatibility".  It was meant to assert
that *not using 'getdtablesize()'*, but using, say, 32, would solve your
problems.  I should have made it clearer in the first paragraph that the
fix to the problem mentioned therein was not simply to change the first
part by passing in pointers to "fd_set"s.

"properly" doesn't just mean "use 'fd_set's"; it means "don't pass the
result of 'getdtablesize()' as the first argument unless you mean it" -
i.e., don't pass the result of 'getdtablesize()' unless you're actually
using file descriptor 'getdtablesize() - 1'.  The proper way to use
"select" - both for reasons of correctness *and* performance (see my
second posting) - is to pass one greater than the highest file descriptor
number you use as the first argument.  Thus, most programs will probably
pass a relatively small number - <= 32 - to "select" as the first
argument. 
Technical Details
Message-ID: <1154@auspex.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request
References: <8902270926.AA24661@grace>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request
From: auspex!guy@uunet.uu.net (Guy Harris)
Newsgroups: comp.sys.sun
Subject: Re: "select" (was "Re. Shared libraries linker error")
Keywords: SunOS
Message-ID: <1154@auspex.UUCP>
Date: 23 Mar 89 21:49:46 GMT
References: <8902270926.AA24661@grace>
Sender: usenet@rice.edu
Organization: Auspex Systems, Santa Clara
Lines: 33
Approved: Sun-Spots@rice.edu
Original-Date: 11 Mar 89 20:54:09 GMT
X-Sun-Spots-Digest: Volume 7, Issue 209, message 7 of 13