mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-02 18:35:00 +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)) {
|
&uc->our_config.channel_reserve_satoshis)) {
|
||||||
log_broken(uc->log, "bad OPENING_FUNDEE_REPLY %s",
|
log_broken(uc->log, "bad OPENING_FUNDEE_REPLY %s",
|
||||||
tal_hex(reply, reply));
|
tal_hex(reply, reply));
|
||||||
tal_free(uc);
|
uncommitted_channel_disconnect(uc, "bad OPENING_FUNDEE_REPLY");
|
||||||
return;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* openingd should never accept them funding channel in this case. */
|
/* openingd should never accept them funding channel in this case. */
|
||||||
if (peer_active_channel(uc->peer)) {
|
if (peer_active_channel(uc->peer)) {
|
||||||
log_broken(uc->log, "openingd accepted peer funding channel");
|
log_broken(uc->log, "openingd accepted peer funding channel");
|
||||||
/* Won't free peer, since has active channel */
|
uncommitted_channel_disconnect(uc, "already have active channel");
|
||||||
tal_free(uc);
|
goto failed;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Consumes uc */
|
/* Consumes uc */
|
||||||
|
@ -483,8 +482,8 @@ static void opening_fundee_finished(struct subd *openingd,
|
||||||
&channel_info,
|
&channel_info,
|
||||||
feerate);
|
feerate);
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
tal_free(uc);
|
uncommitted_channel_disconnect(uc, "Commit channel failed");
|
||||||
return;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_debug(channel->log, "Watching funding tx %s",
|
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);
|
subd_release_channel(openingd, uc);
|
||||||
uc->openingd = NULL;
|
uc->openingd = NULL;
|
||||||
tal_free(uc);
|
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,
|
static void opening_funder_failed(struct subd *openingd, const u8 *msg,
|
||||||
|
|
Loading…
Add table
Reference in a new issue