cancel_timeout?

Lennart Hellström (ERA) Lennart.Hellstrom at era.ericsson.se
Mon Sep 27 07:18:55 UTC 1999


>You need to cancel all outstanding timeouts that are active for a
>given state machine (usually, there's only one, though) so that you
>won't accidentally make a bogus state transition when the timeout goes
>off.

Ah, I c...

>I would say that you probably need to be prepared to cancel some
>timeouts here.   Unfortunately, the code isn't really structured to
>make this easy... :'(

Can't really see what would be difficult with this. I'll just add a nice switch...

>>     case S_REBOOTING:
>>       cancel_timeout (send_request, ip);   /* added by me */
>>     case S_REQUESTING:
>>       cancel_timeout (send_request, ip);   /* added by me */
>>     case S_RENEWING:
>>       cancel_timeout (send_request, ip);
>>       break;

>Why'd you add the two extra cancel_timeout() calls?  They do the same
>thing.  For S_REBOOTING, you'll cancel the timeout three times, and
>you'll cancel it twice for S_REQUESTING.  The statements as they were,
>because of the way C switch statements work, would have canceled the
>timeout exactly once if you were in any of the three states covered by
>the three case statements.   Remember that after a case statement, all
>code is executed up to a break statement or the end of the switch
>statement - a subsequent case statement does _not_ change the flow of
>control following a preceding case statement.

Ehhh :-} Never really thought about it that way.... If I hadn't fogotten the breaks in my added lines it would've been correct. It's neater the way it was before, so I'll just erase my clumsy lines...
Thanks for the lesson!

>			       _MelloN_

	/ Lelle



More information about the dhcp-hackers mailing list