Skip to content

Commit

Permalink
connectd: don't received useless peer fd if we're told to send final …
Browse files Browse the repository at this point in the history
…msg.

We don't need the connection to ourselves!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Dec 20, 2021
1 parent 39c241b commit 8950384
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 14 deletions.
11 changes: 0 additions & 11 deletions connectd/connectd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1812,21 +1812,10 @@ static void peer_final_msg(struct io_conn *conn,
struct peer *peer;
struct node_id id;
u8 *finalmsg;
int peer_fd;

if (!fromwire_connectd_peer_final_msg(tmpctx, msg, &id, &finalmsg))
master_badmsg(WIRE_CONNECTD_PEER_FINAL_MSG, msg);

/* Get the peer_fd for this peer: we don't need it though! */
io_fd_block(io_conn_fd(conn), true);
peer_fd = fdpass_recv(io_conn_fd(conn));
if (peer_fd == -1)
status_failed(STATUS_FAIL_MASTER_IO,
"Getting peer fd after peer_final_msg: %s",
strerror(errno));
close(peer_fd);
io_fd_block(io_conn_fd(conn), false);

/* This can happen if peer hung up on us. */
peer = peer_htable_get(&daemon->peers, &id);
if (peer) {
Expand Down
2 changes: 1 addition & 1 deletion connectd/connectd_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ msgdata,connectd_peer_connected,features,u8,flen
msgtype,connectd_peer_disconnected,2015
msgdata,connectd_peer_disconnected,id,node_id,

# master -> connectd: give message to peer and disconnect. Plus fd for peer
# master -> connectd: give message to peer and disconnect.
msgtype,connectd_peer_final_msg,2003
msgdata,connectd_peer_final_msg,id,node_id,
msgdata,connectd_peer_final_msg,len,u16,
Expand Down
2 changes: 1 addition & 1 deletion lightningd/opening_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void handle_reestablish(struct lightningd *ld,
subd_send_msg(ld->connectd,
take(towire_connectd_peer_final_msg(NULL, peer_id,
err)));
subd_send_fd(ld->connectd, peer_fd);
close(peer_fd);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ static void peer_connected_hook_final(struct peer_connected_hook_payload *payloa
subd_send_msg(ld->connectd,
take(towire_connectd_peer_final_msg(NULL, &peer->id,
error)));
subd_send_fd(ld->connectd, payload->peer_fd);
close(payload->peer_fd);
}

static bool
Expand Down

0 comments on commit 8950384

Please sign in to comment.