Hi,

According to ifstated.conf(5)
"The init block is used to initialise the state and is executed each time the state is entered."

This should be the first thing to be executed right? In debug I see the body executed first.
Isn't the code bellow more reasonable?

--- /tmp/ifstated.c     Fri Mar 25 16:32:13 2011
+++ ifstated.c  Fri Mar 25 16:32:24 2011
@@ -543,9 +543,9 @@
                conf->curstate = conf->nextstate;
                conf->nextstate = NULL;
                conf->curstate->entered = time(NULL);
+               do_action(conf->curstate->init);
                external_evtimer_setup(conf->curstate, IFSD_EVTIMER_ADD);
                adjust_external_expressions(conf->curstate);
-               do_action(conf->curstate->init);
                return (1);
        }
        return (0);

Also one more thing. In the state bellow:
state promoted {
        init {
                run "ifconfig carp0 advskew 101"
                run "ifconfig carp1 advskew 101"
        }
        if $net
                set-state primary
        if ! $net && $peer
                set-state backup
}

Both expressions in the body are evaluated the first time we enter the state. Why? If first expression is true, shouldn't we go directly on primary state without evaluating second if?

thanx

Giannis

Reply via email to