From 024d189a07d05a71117e35c0fde86fe0e6b89f7d Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 19 May 2018 21:54:22 +0100 Subject: [PATCH] server/peer.c: Engage the interval timer only while there are peers. The reason we need the interval timer is (a) to top up the entropy pool, and (b) to clean up old keysets. If there are no peers, we do no key exchange, so we don't need any random bits, and there are no keysets to clear away. So we can save wakeups in this case. For now, there are stub versions of `iv_(add|rm)reason' in `test.c', but these will vanish once we split `main' out into its own file. (Spoiler alert!) --- server/peer.c | 3 +++ server/test.c | 3 +++ server/tripe.c | 2 -- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/server/peer.c b/server/peer.c index fb016169..59a42cde 100644 --- a/server/peer.c +++ b/server/peer.c @@ -992,6 +992,7 @@ peer *p_create(peerspec *spec) T( trace(T_TUNNEL, "peer: attached interface %s to peer `%s'", p->ifname, p_name(p)); ) p_setkatimer(p); + iv_addreason(); if (kx_setup(&p->kx, p, &p->ks, p->spec.f & PSF_KXMASK)) goto tidy_4; a_notify("ADD", @@ -1010,6 +1011,7 @@ tidy_4: if (spec->t_ka) sel_rmtimer(&p->tka); xfree(p->ifname); p->t->ops->destroy(p->t); + iv_rmreason(); tidy_3: if (fd >= 0) close(fd); tidy_2: @@ -1141,6 +1143,7 @@ void p_destroy(peer *p, int bye) } sym_remove(&byname, p->byname); am_remove(&byaddr, p->byaddr); + iv_rmreason(); DESTROY(p); } diff --git a/server/test.c b/server/test.c index 152a6fe6..989bfd39 100644 --- a/server/test.c +++ b/server/test.c @@ -90,6 +90,9 @@ static const char *getarg(void) static void lastarg(void) { if (*args) die(2, "unexpected argument `%s'", *args); } +void iv_addreason(void) { ; } +void iv_rmreason(void) { ; } + int main(int argc, char *argv[]) { const char *kr = "keyring"; diff --git a/server/tripe.c b/server/tripe.c index b4f4cc97..bf217b37 100644 --- a/server/tripe.c +++ b/server/tripe.c @@ -418,8 +418,6 @@ int main(int argc, char *argv[]) a_switcherr(); } - iv_addreason(); - lp_run(); return (0); } -- 2.11.0