On Sun, Jan 01, 2006 at 01:50:58AM +0000, Karl O. Pinc wrote:
> man 5 ifstated.conf says:
>
> "The init block is used
> to initialise the state and is executed each time the
> state is entered."
>
> But this does not seem to be true if you use 'init-state'
> to enter the state. Or maybe there's something else
> wrong with my config below, or with ifstated when there's
> no body. Or something.
Hi,
the problem is that on state changes further set-state actions are
ignored. The patch below should fix that. The issue has already been
reported by Holger Mikolon, whose patch I slightly modified.
However, your config is way too complicated.
That here should do it:
--------------snip-------------
carp_up = "carp0.link.up"
if $carp_up
run "touch /tmp/am_master"
if ! $carp_up
run "rm /tmp/am_master"
--------------snip-------------
But feel free to test the patch as well :-)
Index: ifstated.c
===================================================================
RCS file: /cvs/src/usr.sbin/ifstated/ifstated.c,v
retrieving revision 1.22
diff -u -p -r1.22 ifstated.c
--- ifstated.c 28 Jul 2005 16:59:42 -0000 1.22
+++ ifstated.c 1 Jan 2006 19:10:09 -0000
@@ -69,7 +69,7 @@ void fetch_state(void);
void usage(void);
void adjust_expressions(struct ifsd_expression_list *, int);
void eval_state(struct ifsd_state *);
-void state_change(void);
+int state_change(void);
void do_action(struct ifsd_action *);
void remove_action(struct ifsd_action *, struct ifsd_state *);
void remove_expression(struct ifsd_expression *, struct ifsd_state *);
@@ -494,14 +494,15 @@ eval_state(struct ifsd_state *state)
if (external == NULL || external->lastexec >= state->entered ||
external->lastexec == 0) {
do_action(state->always);
- state_change();
+ while (state_change())
+ do_action(conf->curstate->always);
}
}
/*
*If a previous action included a state change, process it.
*/
-void
+int
state_change(void)
{
if (conf->nextstate != NULL && conf->curstate != conf->nextstate) {
@@ -519,7 +520,9 @@ state_change(void)
fetch_state();
do_action(conf->curstate->init);
fetch_state();
+ return (1);
}
+ return (0);
}
/*