diff --git a/connectd/connectd.c b/connectd/connectd.c index f92f2e187..3aba28ddd 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -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]); diff --git a/gossipd/test/run-bench-find_route.c b/gossipd/test/run-bench-find_route.c index 476053582..0772b7d23 100644 --- a/gossipd/test/run-bench-find_route.c +++ b/gossipd/test/run-bench-find_route.c @@ -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 diff --git a/gossipd/test/run-find_route-specific.c b/gossipd/test/run-find_route-specific.c index 52256dacb..64060092c 100644 --- a/gossipd/test/run-find_route-specific.c +++ b/gossipd/test/run-find_route-specific.c @@ -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 diff --git a/gossipd/test/run-find_route.c b/gossipd/test/run-find_route.c index 609282974..41400bf2c 100644 --- a/gossipd/test/run-find_route.c +++ b/gossipd/test/run-find_route.c @@ -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 diff --git a/gossipd/test/run-overlong.c b/gossipd/test/run-overlong.c index d400aa792..2a16642f7 100644 --- a/gossipd/test/run-overlong.c +++ b/gossipd/test/run-overlong.c @@ -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 diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index f1ddbf6cb..e9cea141b 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -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 diff --git a/lightningd/test/run-invoice-select-inchan.c b/lightningd/test/run-invoice-select-inchan.c index 5634b25b9..c3683f6df 100644 --- a/lightningd/test/run-invoice-select-inchan.c +++ b/lightningd/test/run-invoice-select-inchan.c @@ -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(); } diff --git a/wallet/db_postgres_sqlgen.c b/wallet/db_postgres_sqlgen.c index 9525c7814..87548771d 100644 --- a/wallet/db_postgres_sqlgen.c +++ b/wallet/db_postgres_sqlgen.c @@ -1906,4 +1906,4 @@ struct db_query db_postgres_queries[] = { #endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */ -// SHA256STAMP:435d8c98449934c86167d11929b515312babce55bae5487dc3cdc201cb4ba0fe +// SHA256STAMP:c9d9d585e1fcba900b06f41123aa77c6fbd98945ffe485528c2601323f340bed diff --git a/wallet/db_sqlite3_sqlgen.c b/wallet/db_sqlite3_sqlgen.c index f6121dad1..0dfbe477b 100644 --- a/wallet/db_sqlite3_sqlgen.c +++ b/wallet/db_sqlite3_sqlgen.c @@ -1906,4 +1906,4 @@ struct db_query db_sqlite3_queries[] = { #endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */ -// SHA256STAMP:435d8c98449934c86167d11929b515312babce55bae5487dc3cdc201cb4ba0fe +// SHA256STAMP:c9d9d585e1fcba900b06f41123aa77c6fbd98945ffe485528c2601323f340bed diff --git a/wallet/statements_gettextgen.po b/wallet/statements_gettextgen.po index afd5883f4..f0ce58886 100644 --- a/wallet/statements_gettextgen.po +++ b/wallet/statements_gettextgen.po @@ -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 diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 4401f4468..1043a2a2a 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -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(); }