channeld: fix halting gossip when a timer is active.

We would sleep until the next timer, even if that's long past when we would
send gossip.  Normally we use very short timers, so we didn't notice, but
we will in the next patch, where we use continuous timers for pings.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-10-09 14:38:51 +10:30 committed by Christian Decker
parent 9138ebf807
commit 140b2deec0

View File

@ -3923,15 +3923,21 @@ int main(int argc, char *argv[])
continue;
}
/* Might not be waiting for anything. */
tptr = NULL;
if (timer_earliest(&peer->timers, &first)) {
timeout = timespec_to_timeval(
timemono_between(first, now).ts);
tptr = &timeout;
} else if (time_to_next_gossip(peer->pps, &trel)) {
}
/* If timer to next gossip is sooner, use that instead. */
if (time_to_next_gossip(peer->pps, &trel)
&& (!tptr || time_less(trel, timeval_to_timerel(*tptr)))) {
timeout = timerel_to_timeval(trel);
tptr = &timeout;
} else
tptr = NULL;
}
if (select(nfds, &rfds, NULL, NULL, tptr) < 0) {
/* Signals OK, eg. SIGUSR1 */