mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
peer: free packet when we close connection in init_pkt_in.
Otherwise if they reconnect, we hit the assert in recv_body: assert(!peer->inpkt); Found by testing on my build box *without* valgrind (so it was fast enough to do this). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
69b1b9c562
commit
92e5f53f4d
@ -2118,14 +2118,14 @@ static struct io_plan *init_pkt_in(struct io_conn *conn, struct peer *peer)
|
|||||||
{
|
{
|
||||||
if (peer->inpkt->pkt_case != PKT__PKT_INIT) {
|
if (peer->inpkt->pkt_case != PKT__PKT_INIT) {
|
||||||
peer_received_unexpected_pkt(peer, peer->inpkt, __func__);
|
peer_received_unexpected_pkt(peer, peer->inpkt, __func__);
|
||||||
return pkt_out(conn, peer);
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* They might have missed the error, tell them before hanging up */
|
/* They might have missed the error, tell them before hanging up */
|
||||||
if (state_is_error(peer->state)) {
|
if (state_is_error(peer->state)) {
|
||||||
queue_pkt_err(peer, pkt_err(peer, "In error state %s",
|
queue_pkt_err(peer, pkt_err(peer, "In error state %s",
|
||||||
state_name(peer->state)));
|
state_name(peer->state)));
|
||||||
return pkt_out(conn, peer);
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer->inpkt->init->has_features) {
|
if (peer->inpkt->init->has_features) {
|
||||||
@ -2149,7 +2149,7 @@ static struct io_plan *init_pkt_in(struct io_conn *conn, struct peer *peer)
|
|||||||
pkt_err(peer,
|
pkt_err(peer,
|
||||||
"Unsupported feature %zu",
|
"Unsupported feature %zu",
|
||||||
i));
|
i));
|
||||||
return pkt_out(conn, peer);
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2162,7 +2162,7 @@ static struct io_plan *init_pkt_in(struct io_conn *conn, struct peer *peer)
|
|||||||
if (!state_can_io(peer->state)) {
|
if (!state_can_io(peer->state)) {
|
||||||
log_debug(peer->log, "State %s, closing immediately",
|
log_debug(peer->log, "State %s, closing immediately",
|
||||||
state_name(peer->state));
|
state_name(peer->state));
|
||||||
return pkt_out(conn, peer);
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Back into normal mode. */
|
/* Back into normal mode. */
|
||||||
@ -2172,6 +2172,11 @@ static struct io_plan *init_pkt_in(struct io_conn *conn, struct peer *peer)
|
|||||||
return io_duplex(conn,
|
return io_duplex(conn,
|
||||||
peer_read_packet(conn, peer, pkt_in),
|
peer_read_packet(conn, peer, pkt_in),
|
||||||
pkt_out(conn, peer));
|
pkt_out(conn, peer));
|
||||||
|
|
||||||
|
fail:
|
||||||
|
/* We always free inpkt; they may yet reconnect. */
|
||||||
|
peer->inpkt = tal_free(peer->inpkt);
|
||||||
|
return pkt_out(conn, peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct io_plan *read_init_pkt(struct io_conn *conn,
|
static struct io_plan *read_init_pkt(struct io_conn *conn,
|
||||||
|
Loading…
Reference in New Issue
Block a user