From a1b8b40d135c64e580d6767288a1ca5d6188e54a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 26 Jun 2022 14:01:01 +0930 Subject: [PATCH] connectd: fix debug message on bind fail. It doesn't get the right errno, and it says "create" not "bind". ``` 2022-05-20T03:04:46.498Z DEBUG connectd: Failed to create 2 socket: Success 2022-05-20T03:04:46.500Z DEBUG connectd: REPLY WIRE_CONNECTD_INIT_REPLY with 0 fds 2022-05-20T03:04:46.501Z DEBUG connectd: connectd_init_done 2022-05-20T03:04:46.503Z **BROKEN** connectd: Failed to bind socket for 127.0.0.1:37871: Address already in use ``` Signed-off-by: Rusty Russell --- connectd/connectd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/connectd/connectd.c b/connectd/connectd.c index 474fe8b40..635f251b4 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -1077,14 +1077,14 @@ static struct listen_fd *make_listen_fd(const tal_t *ctx, int on = 1; if (fd < 0) { + const char *es = strerror(errno); *errstr = tal_fmt(ctx, "Failed to create socket for %s%s: %s", is_websocket ? "websocket " : "", type_to_string(tmpctx, struct wireaddr_internal, wi), - strerror(errno)); - status_debug("Failed to create %u socket: %s", - domain, strerror(errno)); + es); + status_debug("Failed to create %u socket: %s", domain, es); return NULL; } @@ -1094,14 +1094,14 @@ static struct listen_fd *make_listen_fd(const tal_t *ctx, strerror(errno)); if (bind(fd, addr, len) != 0) { + const char *es = strerror(errno); *errstr = tal_fmt(ctx, "Failed to bind socket for %s%s: %s", is_websocket ? "websocket " : "", type_to_string(tmpctx, struct wireaddr_internal, wi), - strerror(errno)); - status_debug("Failed to create %u socket: %s", - domain, strerror(errno)); + es); + status_debug("Failed to bind %u socket: %s", domain, es); goto fail; }