The use of the select statement in omapi/dispatch.c

dhcp at softsysgrp.com dhcp at softsysgrp.com
Thu Aug 22 23:37:17 UTC 2002


I agree with everything you say below, I was just questioning the
implementation. The select call does take a timeout pointer value, and
(struct timeval *)0 is a pointer value that points to address 0 which I
don't think is the same as a pointer to a variable that has been set to
zero. Real address 0 may contain a zero on POSIX systems, but I was just
suggesting that for the purposes of porting to other systems, that it would
be better to call select with a pointer value that points to a variable and
not a hard address such as 0.

My problem was that I changed the timeout parameter to (struct timeval
*)1000 which is not a pointer to 1000. It says that the value of the pointer
is 1000 and that the value of the timeout will be found at address 1000.
This lead to interesting timeout values in my environment depending whether
I had a breakpoint set at 1000 or not.

-----Original Message-----
From: dhcp-hackers-bounce at isc.org [mailto:dhcp-hackers-bounce at isc.org]On
Behalf Of Ted Lemon
Sent: Thursday, August 22, 2002 6:59 PM
To: dhcp-hackers at isc.org
Subject: Re: The use of the select statement in omapi/dispatch.c


> The select statement below is used in the code and I think one of the
> parameters is incorrect, or incorrect in non unix systems. The timeout
> variable should be passed by address and the way it is written we are
> passing a 0 address which would tell the select code to go to location 0
> to
> get the timeout value. As I recall, under unix systems, programs are
> protected from using address 0 by the fact that a 0 is always in location
> 0.

The select system call is supposed to take a timeout pointer value of zero
to mean no timeout, not timeout immediately.   If your operating system
does not support this, it's not compatible.   select is a bsd thing, and
AFAIK is not included in POSIX, so this isn't a terrible faux pas, but the
problem is with the operating system, not the code in dispatch.c.



More information about the dhcp-hackers mailing list