lightningd: use connectd to send the final error message, not openingd/dualopend

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-06-03 12:52:21 +09:30
parent 7cffea10ce
commit e2f225e4cd
11 changed files with 47 additions and 25 deletions

View File

@ -1654,6 +1654,7 @@ static struct io_plan *peer_final_msg(struct io_conn *conn,
u8 *finalmsg;
int fds[3];
f->daemon = daemon;
/* pps is allocated off f, so fds are closed when f freed. */
if (!fromwire_connectd_peer_final_msg(f, msg, &f->id, &pps, &finalmsg))
master_badmsg(WIRE_CONNECTD_PEER_FINAL_MSG, msg);
@ -1662,8 +1663,16 @@ static struct io_plan *peer_final_msg(struct io_conn *conn,
tal_add_destructor(f, destroy_final_msg_data);
/* Get the fds for this peer. */
for (size_t i = 0; i < ARRAY_SIZE(fds); i++)
io_fd_block(io_conn_fd(conn), true);
for (size_t i = 0; i < ARRAY_SIZE(fds); i++) {
fds[i] = fdpass_recv(io_conn_fd(conn));
if (fds[i] == -1)
status_failed(STATUS_FAIL_MASTER_IO,
"Getting fd %zu after peer_final_msg: %s",
i, strerror(errno));
}
io_fd_block(io_conn_fd(conn), false);
/* We put peer fd into conn, but pps needs to free the rest */
per_peer_state_set_fds(pps, -1, fds[1], fds[2]);

View File

@ -92,9 +92,6 @@ u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
/* Generated stub for update_peers_broadcast_index */
void update_peers_broadcast_index(struct list_head *peers UNNEEDED, u32 offset UNNEEDED)
{ fprintf(stderr, "update_peers_broadcast_index called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
#if DEVELOPER

View File

@ -78,9 +78,6 @@ u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
/* Generated stub for update_peers_broadcast_index */
void update_peers_broadcast_index(struct list_head *peers UNNEEDED, u32 offset UNNEEDED)
{ fprintf(stderr, "update_peers_broadcast_index called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
#if DEVELOPER

View File

@ -78,9 +78,6 @@ u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
/* Generated stub for update_peers_broadcast_index */
void update_peers_broadcast_index(struct list_head *peers UNNEEDED, u32 offset UNNEEDED)
{ fprintf(stderr, "update_peers_broadcast_index called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
#if DEVELOPER

View File

@ -78,9 +78,6 @@ u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
/* Generated stub for update_peers_broadcast_index */
void update_peers_broadcast_index(struct list_head *peers UNNEEDED, u32 offset UNNEEDED)
{ fprintf(stderr, "update_peers_broadcast_index called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
#if DEVELOPER

View File

@ -1136,10 +1136,6 @@ static void peer_connected_hook_final(struct peer_connected_hook_payload *payloa
notify_connect(ld, &peer->id, payload->incoming, &addr);
/* No err, all good. */
error = NULL;
send_error:
if (feature_negotiated(ld->our_features,
peer->their_features,
OPT_DUAL_FUND)) {
@ -1150,11 +1146,28 @@ send_error:
|| channel->state == AWAITING_UNILATERAL);
channel->peer->addr = addr;
channel->peer->connected_incoming = payload->incoming;
peer_restart_dualopend(peer, payload->pps, channel, error);
peer_restart_dualopend(peer, payload->pps, channel, NULL);
} else
peer_start_dualopend(peer, payload->pps, error);
peer_start_dualopend(peer, payload->pps, NULL);
} else
peer_start_openingd(peer, payload->pps, error);
peer_start_openingd(peer, payload->pps, NULL);
return;
send_error:
log_debug(ld->log, "Telling connectd to send error %s",
tal_hex(tmpctx, error));
/* Get connectd to send error and close. */
subd_send_msg(ld->connectd,
take(towire_connectd_peer_final_msg(NULL, &peer->id,
payload->pps, error)));
subd_send_fd(ld->connectd, payload->pps->peer_fd);
subd_send_fd(ld->connectd, payload->pps->gossip_fd);
subd_send_fd(ld->connectd, payload->pps->gossip_store_fd);
/* Don't close those fds! */
payload->pps->peer_fd
= payload->pps->gossip_fd
= payload->pps->gossip_store_fd
= -1;
}
static bool

View File

@ -613,6 +613,9 @@ void subd_req_(const tal_t *ctx UNNEEDED,
void (*replycb)(struct subd * UNNEEDED, const u8 * UNNEEDED, const int * UNNEEDED, void *) UNNEEDED,
void *replycb_data UNNEEDED)
{ fprintf(stderr, "subd_req_ called!\n"); abort(); }
/* Generated stub for subd_send_fd */
void subd_send_fd(struct subd *sd UNNEEDED, int fd UNNEEDED)
{ fprintf(stderr, "subd_send_fd called!\n"); abort(); }
/* Generated stub for subd_send_msg */
void subd_send_msg(struct subd *sd UNNEEDED, const u8 *msg_out UNNEEDED)
{ fprintf(stderr, "subd_send_msg called!\n"); abort(); }
@ -637,6 +640,9 @@ u8 *towire_channeld_specific_feerates(const tal_t *ctx UNNEEDED, u32 feerate_bas
/* Generated stub for towire_connectd_connect_to_peer */
u8 *towire_connectd_connect_to_peer(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, u32 seconds_waited UNNEEDED, const struct wireaddr_internal *addrhint UNNEEDED)
{ fprintf(stderr, "towire_connectd_connect_to_peer called!\n"); abort(); }
/* Generated stub for towire_connectd_peer_final_msg */
u8 *towire_connectd_peer_final_msg(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, const struct per_peer_state *pps UNNEEDED, const u8 *msg UNNEEDED)
{ fprintf(stderr, "towire_connectd_peer_final_msg called!\n"); abort(); }
/* Generated stub for towire_dualopend_send_shutdown */
u8 *towire_dualopend_send_shutdown(const tal_t *ctx UNNEEDED, const u8 *shutdown_scriptpubkey UNNEEDED)
{ fprintf(stderr, "towire_dualopend_send_shutdown called!\n"); abort(); }

View File

@ -1906,4 +1906,4 @@ struct db_query db_postgres_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
// SHA256STAMP:435d8c98449934c86167d11929b515312babce55bae5487dc3cdc201cb4ba0fe
// SHA256STAMP:c9d9d585e1fcba900b06f41123aa77c6fbd98945ffe485528c2601323f340bed

View File

@ -1906,4 +1906,4 @@ struct db_query db_sqlite3_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
// SHA256STAMP:435d8c98449934c86167d11929b515312babce55bae5487dc3cdc201cb4ba0fe
// SHA256STAMP:c9d9d585e1fcba900b06f41123aa77c6fbd98945ffe485528c2601323f340bed

View File

@ -1250,11 +1250,11 @@ msgstr ""
msgid "not a valid SQL statement"
msgstr ""
#: wallet/test/run-wallet.c:1449
#: wallet/test/run-wallet.c:1455
msgid "SELECT COUNT(1) FROM channel_funding_inflights WHERE channel_id = ?;"
msgstr ""
#: wallet/test/run-wallet.c:1647
#: wallet/test/run-wallet.c:1653
msgid "INSERT INTO channels (id) VALUES (1);"
msgstr ""
# SHA256STAMP:fdfbb1278ba9e09884c9205e54fc16bb9e66a0362a5aaad11a7efd42746d8e72
# SHA256STAMP:ef55222dd765f18ae8d8f000c51b6024bbe7acafc17dd0b6837a180d7b736270

View File

@ -706,6 +706,9 @@ void subd_req_(const tal_t *ctx UNNEEDED,
void (*replycb)(struct subd * UNNEEDED, const u8 * UNNEEDED, const int * UNNEEDED, void *) UNNEEDED,
void *replycb_data UNNEEDED)
{ fprintf(stderr, "subd_req_ called!\n"); abort(); }
/* Generated stub for subd_send_fd */
void subd_send_fd(struct subd *sd UNNEEDED, int fd UNNEEDED)
{ fprintf(stderr, "subd_send_fd called!\n"); abort(); }
/* Generated stub for subd_send_msg */
void subd_send_msg(struct subd *sd UNNEEDED, const u8 *msg_out UNNEEDED)
{ fprintf(stderr, "subd_send_msg called!\n"); abort(); }
@ -760,6 +763,9 @@ u8 *towire_connectd_connect_to_peer(const tal_t *ctx UNNEEDED, const struct node
/* Generated stub for towire_connectd_peer_disconnected */
u8 *towire_connectd_peer_disconnected(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED)
{ fprintf(stderr, "towire_connectd_peer_disconnected called!\n"); abort(); }
/* Generated stub for towire_connectd_peer_final_msg */
u8 *towire_connectd_peer_final_msg(const tal_t *ctx UNNEEDED, const struct node_id *id UNNEEDED, const struct per_peer_state *pps UNNEEDED, const u8 *msg UNNEEDED)
{ fprintf(stderr, "towire_connectd_peer_final_msg called!\n"); abort(); }
/* Generated stub for towire_custommsg_out */
u8 *towire_custommsg_out(const tal_t *ctx UNNEEDED, const u8 *msg UNNEEDED)
{ fprintf(stderr, "towire_custommsg_out called!\n"); abort(); }