Skip to content

Commit

Permalink
peer: commit outstanding changes before sending PKT_CLOSE.
Browse files Browse the repository at this point in the history
Pierre points out that we don't handle this, and it can happen due
to race; the spec says we are not supposed to send PKT_CLOSE with
uncommitted changes.

Closes: #29
Reported-by: Pierre-Marie Padiou
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Nov 8, 2016
1 parent 3380819 commit bd1cdf6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions daemon/peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,10 @@ static bool peer_start_shutdown(struct peer *peer)
enum state newstate;
u8 *redeemscript;

/* We might have uncommited changes; if so, commit them now. */
if (!do_commit(peer, NULL))
return false;

db_start_transaction(peer);

db_begin_shutdown(peer);
Expand Down

0 comments on commit bd1cdf6

Please sign in to comment.