channeld: accept SHUTDOWN before channel is locked.

Fixes: #1308
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-04-03 16:38:53 +09:30 committed by Christian Decker
parent 71de234255
commit 1773b03380
2 changed files with 5 additions and 3 deletions

View File

@ -1589,7 +1589,9 @@ static void peer_in(struct peer *peer, const u8 *msg)
/* Must get funding_locked before almost anything. */
if (!peer->funding_locked[REMOTE]) {
if (type != WIRE_FUNDING_LOCKED && type != WIRE_PONG) {
if (type != WIRE_FUNDING_LOCKED
&& type != WIRE_PONG
&& type != WIRE_SHUTDOWN) {
peer_failed(&peer->cs,
peer->gossip_index,
&peer->channel_id,

View File

@ -77,9 +77,9 @@ static void peer_got_shutdown(struct channel *channel, const u8 *msg)
}
/* If we weren't already shutting down, we are now */
if (channel->state == CHANNELD_NORMAL)
if (channel->state != CHANNELD_SHUTTING_DOWN)
channel_set_state(channel,
CHANNELD_NORMAL, CHANNELD_SHUTTING_DOWN);
channel->state, CHANNELD_SHUTTING_DOWN);
/* TODO(cdecker) Selectively save updated fields to DB */
wallet_channel_save(ld->wallet, channel);