rtems_dhcp.c: dhcp_task() bug? plus question

Arnout Vandecappelle arnout at mind.be
Mon Nov 3 08:45:46 UTC 2008


On Thursday 30 October 2008 18:00:18 Gene Smith wrote:
> Looking with a debugger, I noticed that dhcp_task(), which I think just
> checks when to do a lease renewal, was exiting the first time it ran.
> The only way it should ever exit is if an event is received from the
> dhcp failsafe code, which I am not running, indicating the interface has
> gone down. In the task, the function rtems_event_receive() would wait
> for a second and return, as it should. But the check was for event_out
> to contain bit RTEMS_EVENT_0. But since no event actually was received
> (it really did time out) the event_out was never set by
> rtems_event_received() and contained a random value.
>
> The solution I think is to
>
> 1) Initialize event_out to 0 when it is declared or
> 2) Check the return on rtems_event() !RTEMS_TIMEOUT and exit on that
> condition.
>
> Right now I am doing the 2nd option.

 Yep that's a bug and a correct fix.

> My question is why does this task poll every seconds? Seems like it
> could be a minute or more since leases are usually in terms of hours, I
> think, and it renews at the half-way point.

 I don't see any real reason to work that way.  When I modified the dhcp_task, 
I left that bit as-is to avoid breaking things :-) .  One could argue that 
this way, when an error occurs, the DHCP request is repeated every second, 
but there are better ways to code that...

 Regards,
 Arnout

-- 
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  D206 D44B 5155 DF98 550D  3F2A 2213 88AA A1C7 C933



More information about the users mailing list