From 9498e14530fea53167b4fa2488446643b60e7595 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 24 Jul 2022 15:48:55 +0930 Subject: [PATCH] connectd: two logging cleanups. Don't log_io final messages twice (multiplex_final_message already does this, so it's confusing to see us send e.g. WIRE_ERROR twice!). And report that the peer has failed to connect out *before* telling lightningd, otherwise we get a very confusing ordering, e.g.: ``` 2022-07-23T05:17:36.096Z DEBUG 027d0de66d08f956a8d606c0d1c34e59bda38c05a3b1cc738fdd6378716c644997-lightningd: Reconnecting in 4 seconds 2022-07-23T05:17:36.096Z DEBUG 027d0de66d08f956a8d606c0d1c34e59bda38c05a3b1cc738fdd6378716c644997-lightningd: Will try reconnect in 4 seconds 2022-07-23T05:17:36.096Z DEBUG 027d0de66d08f956a8d606c0d1c34e59bda38c05a3b1cc738fdd6378716c644997-connectd: Failed connected out: ``` Signed-off-by: Rusty Russell --- connectd/connectd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/connectd/connectd.c b/connectd/connectd.c index ac52cc421..dbf03d039 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -652,6 +652,8 @@ static void connect_failed(struct daemon *daemon, if (wait_seconds < INITIAL_WAIT_SECONDS) wait_seconds = INITIAL_WAIT_SECONDS; + status_peer_debug(id, "Failed connected out: %s", errmsg); + /* lightningd may have a connect command waiting to know what * happened. We leave it to lightningd to decide if it wants to try * again, with the wait_seconds as a hint of how long before @@ -659,8 +661,6 @@ static void connect_failed(struct daemon *daemon, msg = towire_connectd_connect_failed(NULL, id, errcode, errmsg, wait_seconds, addrhint); daemon_conn_send(daemon->master, take(msg)); - - status_peer_debug(id, "Failed connected out: %s", errmsg); } /* add errors to error list */ @@ -1887,11 +1887,8 @@ static void peer_final_msg(struct io_conn *conn, /* This can happen if peer hung up on us (or wrong counter * if it reconnected). */ peer = peer_htable_get(&daemon->peers, &id); - if (peer && peer->counter == counter) { - /* Log message for peer. */ - status_peer_io(LOG_IO_OUT, &id, finalmsg); + if (peer && peer->counter == counter) multiplex_final_msg(peer, take(finalmsg)); - } } #if DEVELOPER