Another point of view re sys_select behavior.

David Collier-Brown davecb at canada.sun.com
Wed May 10 18:30:51 GMT 2000


Ron Alexander wrote:
> 
> We use the Book "Advanced Programming in the UNIX Environment" by W. Richard
> Stevens as our reference.
> 
> On page 399 of Stevens the last para. deals with the select situation.
> As usual, there are 2 behaviors for timeout. 4.3+BSD does NOT change the
> desc. set while SVR4 clears the set.

	Neither change the set on error.

> The VOS implementation is the BSD version. Samba assumes SVR4 behavior.
> The patch that David supplied is ok, but only deals with one caller of
> sys_select.
> The real fix must be made in system.c.
> The question then is if the Samba sys_select should be BSD or SVR4 style.
> The simple fix is to adopt SVR4 since clearing the fd's is less overhead
> than restoring them.
> See client.c wait_keyboard for another example of code that will fail.

	Yup, but that is an orthogonal case to this one.

	There are three possible errors from select, and
	two possible successes (the second is a timeout).
	the code handles one error and both successes, but
	thinks the other two errors are successes.

	That is, regrettably, A Very Bad Thing

	I therefor turned this into a three-possibility
	check: success, failure (any of the three) or timeout.
	It is the least code to cover the cases, and I strongly
	recommend the team apply the fix or an equivalent one.

	Thanks, Ron!

--dave
-- 
David Collier-Brown,  | Always do right. This will gratify some people
185 Ellerslie Ave.,   | and astonish the rest.        -- Mark Twain
Willowdale, Ontario   | //www.oreilly.com/catalog/samba/author.html
Work: (905) 415-2849 Home: (416) 223-8968 Email: davecb at canada.sun.com


More information about the samba-technical mailing list