mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
opening_control.c: make sure we always clean up in error cases.
Especially by closing the file descriptors we were handed! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
035362e151
commit
8b5c80f42a
1 changed files with 12 additions and 7 deletions
|
@ -459,16 +459,15 @@ static void opening_fundee_finished(struct subd *openingd,
|
|||
&uc->our_config.channel_reserve_satoshis)) {
|
||||
log_broken(uc->log, "bad OPENING_FUNDEE_REPLY %s",
|
||||
tal_hex(reply, reply));
|
||||
tal_free(uc);
|
||||
return;
|
||||
uncommitted_channel_disconnect(uc, "bad OPENING_FUNDEE_REPLY");
|
||||
goto failed;
|
||||
}
|
||||
|
||||
/* openingd should never accept them funding channel in this case. */
|
||||
if (peer_active_channel(uc->peer)) {
|
||||
log_broken(uc->log, "openingd accepted peer funding channel");
|
||||
/* Won't free peer, since has active channel */
|
||||
tal_free(uc);
|
||||
return;
|
||||
uncommitted_channel_disconnect(uc, "already have active channel");
|
||||
goto failed;
|
||||
}
|
||||
|
||||
/* Consumes uc */
|
||||
|
@ -483,8 +482,8 @@ static void opening_fundee_finished(struct subd *openingd,
|
|||
&channel_info,
|
||||
feerate);
|
||||
if (!channel) {
|
||||
tal_free(uc);
|
||||
return;
|
||||
uncommitted_channel_disconnect(uc, "Commit channel failed");
|
||||
goto failed;
|
||||
}
|
||||
|
||||
log_debug(channel->log, "Watching funding tx %s",
|
||||
|
@ -502,6 +501,12 @@ static void opening_fundee_finished(struct subd *openingd,
|
|||
subd_release_channel(openingd, uc);
|
||||
uc->openingd = NULL;
|
||||
tal_free(uc);
|
||||
return;
|
||||
|
||||
failed:
|
||||
close(fds[0]);
|
||||
close(fds[1]);
|
||||
tal_free(uc);
|
||||
}
|
||||
|
||||
static void opening_funder_failed(struct subd *openingd, const u8 *msg,
|
||||
|
|
Loading…
Add table
Reference in a new issue