rtems_dhcp.c: dhcp_task() bug? plus question [put in 4.9.1 ?]

Gene Smith gds at chartertn.net
Wed Nov 19 18:02:47 UTC 2008


Joel,
I put this into bugzilla report 1338 with a patch for possibly inclusion 
in 4.9.1.
-gene

Arnout Vandecappelle wrote:
> 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
> 




More information about the users mailing list