struct proto *p = SKIP_BACK(struct proto, glob_node, nn);
#define WALK_PROTO_LIST_END } } while(0)
+#define PD(pr, msg, args...) do { if (pr->debug & D_STATES) { log(L_TRACE "%s: " msg, pr->name , ## args); } } while(0)
+
list active_proto_list;
static list inactive_proto_list;
static list initial_proto_list;
static int proto_flush_all(void *);
static void proto_rethink_goal(struct proto *p);
+static char *proto_state_name(struct proto *p);
static void
proto_enqueue(list *l, struct proto *p)
{
list *l;
+ PD(p, "State changed to %s", proto_state_name(p));
rem_node(&p->n);
switch (p->core_state)
{
if (!p->rt_notify)
return NULL;
DBG("Connecting protocol %s to table %s\n", p->name, t->name);
+ PD(p, "Connected to table %s", t->name);
h = mb_alloc(p->pool, sizeof(struct announce_hook));
h->table = t;
h->proto = p;
c->name = pr->name;
c->out_filter = FILTER_REJECT;
c->table = c->global->master_rtc;
+ c->debug = new_config->proto_default_debug;
return c;
}
q->core_state = FS_HUNGRY;
proto_enqueue(&initial_proto_list, q);
add_tail(&proto_list, &q->glob_node);
+ PD(q, "Initializing");
return q;
}
if (p->proto->reconfigure && p->proto->reconfigure(p, nc))
{
DBG("\t%s: same\n", oc->name);
+ PD(p, "Reconfigured");
p->cf = nc;
p->name = nc->name;
nc->proto = p;
}
/* Unsuccessful, force reconfig */
DBG("\t%s: power cycling\n", oc->name);
+ PD(p, "Reconfiguration failed, restarting");
p->cf_new = nc;
nc->proto = p;
}
else
{
DBG("\t%s: deleting\n", oc->name);
+ PD(p, "Unconfigured");
p->cf_new = NULL;
}
p->reconfiguring = 1;
if (p->core_state == FS_HUNGRY && p->proto_state == PS_DOWN)
{
DBG("Kicking %s up\n", p->name);
+ PD(p, "Starting");
proto_init_instance(p);
proto_notify_state(p, (q->start ? q->start(p) : PS_UP));
}
if (p->proto_state == PS_START || p->proto_state == PS_UP)
{
DBG("Kicking %s down\n", p->name);
+ PD(p, "Shutting down");
proto_notify_state(p, (q->shutdown ? q->shutdown(p) : PS_DOWN));
}
}