X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=site.c;h=22cffbd82a5e543da8e62ed8ad1d1a5ed1c2e84a;hb=564022994befb8f71b89ae015751b22c34ae3ee8;hp=ee4c3100e1345055ed9ebccefb88dbdc6e3e541f;hpb=df16d73e458739ba66c1c6a1fb07f57b3ddcd5c4;p=secnet.git diff --git a/site.c b/site.c index ee4c310..22cffbd 100644 --- a/site.c +++ b/site.c @@ -1712,8 +1712,9 @@ static void set_link_quality(struct site *st) static void enter_state_run(struct site *st) { - slog(st,LOG_STATE,"entering state RUN%s", - current_valid(st) ? " (keyed)" : " (unkeyed)"); + if (st->state!=SITE_STOP) + slog(st,LOG_STATE,"entering state RUN%s", + current_valid(st) ? " (keyed)" : " (unkeyed)"); st->state=SITE_RUN; st->timeout=0; @@ -2283,14 +2284,13 @@ static bool_t site_incoming(void *sst, struct buffer_if *buf, return False; } -static void site_control(void *vst, bool_t run) +static void site_startup(void *vst) { struct site *st=vst; - if (run) enter_state_run(st); - else enter_state_stop(st); + enter_state_run(st); } -static void site_phase_hook(void *sst, uint32_t newphase) +static void site_phase_shutdown_hook(void *sst, uint32_t newphase) { struct site *st=sst; @@ -2298,6 +2298,13 @@ static void site_phase_hook(void *sst, uint32_t newphase) send_msg7(st,"shutting down"); } +static void site_phase_run_hook(void *sst, uint32_t newphase) +{ + struct site *st=sst; + slog(st,LOG_STATE,"entering phase RUN in state %s", + state_name(st->state)); +} + static void site_childpersist_clearkeys(void *sst, uint32_t newphase) { struct site *st=sst; @@ -2331,7 +2338,7 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context, st->cl.apply=NULL; st->cl.interface=&st->ops; st->ops.st=st; - st->ops.control=site_control; + st->ops.startup=site_startup; st->ops.status=site_status; st->peerkeys_path=0; st->peerkeys_tmpl.buffer=0; @@ -2401,7 +2408,7 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context, cfgfatal(loc,"site","%s is not a closure\n",dictkey); \ closure_t *cl=item->data.closure; \ if (cl->type!=CL_TYPE) \ - cfgfatal(loc,"site","%s closure wrong type\n",dictkey); \ + cfgfatal_cl_type(loc,"site",cl,CL_TYPE,dictkey); \ st->things[i]=cl->interface; \ } \ }while(0) @@ -2552,7 +2559,8 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context, enter_state_stop(st); - add_hook(PHASE_SHUTDOWN,site_phase_hook,st); + add_hook(PHASE_SHUTDOWN,site_phase_shutdown_hook,st); + add_hook(PHASE_RUN, site_phase_run_hook, st); add_hook(PHASE_CHILDPERSIST,site_childpersist_clearkeys,st); return new_closure(&st->cl); @@ -2734,8 +2742,10 @@ static void transport_peers_init(struct site *st, transport_peers *peers) { peers->npeers= 0; } static void transport_peers_clear(struct site *st, transport_peers *peers) { + bool_t need_debug=!!peers->npeers; peers->npeers= 0; - transport_peers_debug(st,peers,"clear",0,0,0); + if (need_debug) + transport_peers_debug(st,peers,"clear",0,0,0); } static void transport_peers_copy(struct site *st, transport_peers *dst, const transport_peers *src) {