rtems_dhcp.c: dhcp_task() bug? plus question

Gene Smith gds at chartertn.net
Thu Oct 30 17:00:18 UTC 2008

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 

Right now I am doing the 2nd option.

I will submit a patch in bugzilla if that seem appropriate.

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.


More information about the users mailing list