diff --git a/connectd/connectd.c b/connectd/connectd.c index 703660913..68ea866b3 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -1657,6 +1657,7 @@ static struct io_plan *(*get_in_cb(enum is_websocket is_websocket))(struct io_co static void connect_activate(struct daemon *daemon, const u8 *msg) { bool do_listen; + char *errmsg = NULL; if (!fromwire_connectd_activate(msg, &do_listen)) master_badmsg(WIRE_CONNECTD_ACTIVATE, msg); @@ -1667,12 +1668,13 @@ static void connect_activate(struct daemon *daemon, const u8 *msg) if (listen(daemon->listen_fds[i]->fd, 64) != 0) { if (daemon->listen_fds[i]->mayfail) continue; - status_failed(STATUS_FAIL_INTERNAL_ERROR, - "Failed to listen on socket %s: %s", - type_to_string(tmpctx, - struct wireaddr_internal, - &daemon->listen_fds[i]->wi), - strerror(errno)); + errmsg = tal_fmt(tmpctx, + "Failed to listen on socket %s: %s", + type_to_string(tmpctx, + struct wireaddr_internal, + &daemon->listen_fds[i]->wi), + strerror(errno)); + break; } notleak(io_new_listener(daemon, daemon->listen_fds[i]->fd, @@ -1687,7 +1689,7 @@ static void connect_activate(struct daemon *daemon, const u8 *msg) /* OK, we're ready! */ daemon_conn_send(daemon->master, - take(towire_connectd_activate_reply(NULL))); + take(towire_connectd_activate_reply(NULL, errmsg))); } /* BOLT #10: diff --git a/connectd/connectd_wire.csv b/connectd/connectd_wire.csv index 5f3409042..63ef72f3e 100644 --- a/connectd/connectd_wire.csv +++ b/connectd/connectd_wire.csv @@ -40,6 +40,7 @@ msgdata,connectd_activate,listen,bool, # Connectd->master, I am ready. msgtype,connectd_activate_reply,2125 +msgdata,connectd_activate_reply,failmsg,?wirestring, # connectd->master: disconnect this peer please (due to reconnect). msgtype,connectd_reconnected,2112 diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c index cbde80d11..322ceb69f 100644 --- a/lightningd/connect_control.c +++ b/lightningd/connect_control.c @@ -471,7 +471,7 @@ static void connect_init_done(struct subd *connectd, &ld->binding, &ld->announcable, &errmsg)) - fatal("Bad connectd_activate_reply: %s", + fatal("Bad connectd_init_reply: %s", tal_hex(reply, reply)); /* connectd can fail in *informative* ways: don't use fatal() here and @@ -549,10 +549,22 @@ int connectd_init(struct lightningd *ld) } static void connect_activate_done(struct subd *connectd, - const u8 *reply UNUSED, + const u8 *reply, const int *fds UNUSED, void *unused UNUSED) { + char *errmsg; + if (!fromwire_connectd_activate_reply(reply, reply, &errmsg)) + fatal("Bad connectd_activate_reply: %s", + tal_hex(reply, reply)); + + /* connectd can fail in *informative* ways: don't use fatal() here and + * confuse things with a backtrace! */ + if (errmsg) { + log_broken(connectd->log, "%s", errmsg); + exit(1); + } + /* Break out of loop, so we can begin */ io_break(connectd); }