chiark / gitweb /
svc/watch.in: Fix startup scan to initialize unwatched connections.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 23 Apr 2012 16:49:30 +0000 (17:49 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 23 Apr 2012 17:38:43 +0000 (18:38 +0100)
commit97bbf88a16b0c79af6dca6ec426a24781f2cfd7e
tree583173fa43816101c81dc85c1fbee25ea72846f4
parent220025b91505015253464e09e0d1e3aab26ac294
svc/watch.in: Fix startup scan to initialize unwatched connections.

There's no point defining connection parameters for a peer unless
something's going to act on them, and that something is watch(8).  On
startup (the `--startup' switch), we're meant to notice existing peers
(probably established by connect(8)) and ensure that they're set up
properly.  This initial pass over the peer list is done by
Pinger.rescan, which /usually/ is interested only in watched peers that
need pinging.  It therefore ignores unwatched peers, with the result
that pre-existing unwatched peers are left unconfigured.  Subsequent
peers are detected through the notification mechanism and processed by
the addpeers function which works correctly.

Now, if startup is set, Pinger.rescan tracks all peers and invokes
addpeer on them.

The code relies on the fact that a startup scan is done only once, when
the peer list is empty.  Otherwise it'll reconfigure existing peers,
which is probably a mistake.
svc/watch.in