From 6a05f240d3b913c8e98b7b4aa5d619c18446ec7e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 2 Sep 2025 14:13:57 +0930 Subject: [PATCH] connectd: fix diagnostics if we get a long delay. In a0fd72eb5e0 I added a diagnostic message if messages cause large delays, *but* I didn't set the "peer_in_lasttime" variable in the case of locally-handled packets. I really want this in the release: the point of this was to try to diagnose some high-latency ping issues we've seen on the real network. Signed-off-by: Rusty Russell --- connectd/multiplex.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/connectd/multiplex.c b/connectd/multiplex.c index 8740905b1..d7cbf80e2 100644 --- a/connectd/multiplex.c +++ b/connectd/multiplex.c @@ -1093,6 +1093,7 @@ static struct io_plan *write_to_peer(struct io_conn *peer_conn, if (!msg) { /* Tell them to read again, */ io_wake(&peer->subds); + io_wake(&peer->peer_in); /* Wait for them to wake us */ return msg_queue_wait(peer_conn, peer->peer_outq, @@ -1266,8 +1267,11 @@ static struct io_plan *read_body_from_peer_done(struct io_conn *peer_conn, return next_read(peer_conn, peer); /* If we swallow this, just try again. */ - if (handle_message_locally(peer, decrypted)) - return next_read(peer_conn, peer); + if (handle_message_locally(peer, decrypted)) { + /* Make sure to update peer->peer_in_lastmsg so we blame correct msg! */ + io_wake(peer->peer_outq); + goto out; + } /* After this we should be able to match to subd by channel_id */ if (!extract_channel_id(decrypted, &channel_id)) { @@ -1334,6 +1338,7 @@ static struct io_plan *read_body_from_peer_done(struct io_conn *peer_conn, /* Wait for them to wake us */ peer->peer_in_lastmsg = type; +out: peer->peer_in_lasttime = time_mono(); return io_wait(peer_conn, &peer->peer_in, next_read, peer);