chiark / gitweb /
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.