[PATCH] dhcprelay

Bernd Petrovitsch bernd at firmix.at
Fri Sep 22 13:02:16 UTC 2006


On Fri, 2006-09-22 at 14:51 +0200, walter harms wrote:
> +	while (!dhcprelay_stopflag) {
> +		FD_ZERO(&rfds);
> +		for (i=0; i < num_sockets; i++) FD_SET(fds[i], &rfds);
> +		tv.tv_sec = SELECT_TIMEOUT;
> +		tv.tv_usec = 0;
> +		i = select(max_socket + 1, &rfds, NULL, NULL, &tv);
> +		if (select(max_socket + 1, &rfds, NULL, NULL, &tv) > 0){
> +			/* server */
> 
> hi jesse,
> please take a look at the code above, there is something i do not understand.
> 
> do you realy need to set fds[] every time in the loop ?

Yes, because select(2) modifies the bitmap and returns on which fd you
can actually read something.

> why 2 select() ?

This really looks really wrong (and it was not seen during testing since
the second returns "immediately" since there *are* fds to read from).

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services




More information about the busybox mailing list