chiark / gitweb /
server/peer.c: Engage the interval timer only while there are peers.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 19 May 2018 20:54:22 +0000 (21:54 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 25 Jan 2019 12:10:32 +0000 (12:10 +0000)
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
server/test.c
server/tripe.c

index fb016169acfc70d4fae4215ca8fbe947613b8ee6..59a42cdefe457460fdd378ee3a15122771c1d259 100644 (file)
@@ -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);
 }
 
index 152a6fe6b7d76bba1c7f7b40152856f4749e37b5..989bfd39b44bb6a2d23d080b7a10bf34df24f605 100644 (file)
@@ -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";
index b4f4cc972ab55747d484e40f2030d84f079f8889..bf217b377079835900b8fd2895cf8385330d4e64 100644 (file)
@@ -418,8 +418,6 @@ int main(int argc, char *argv[])
     a_switcherr();
   }
 
-  iv_addreason();
-
   lp_run();
   return (0);
 }