peer: commit outstanding changes before sending PKT_CLOSE.

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>
This commit is contained in:
Rusty Russell
2016-11-08 21:59:55 +10:30
parent 16cff6951f
commit 4151537b71

View File

@@ -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);