Skip to content

Commit

Permalink
lightningd: remove htlc_set destruction timer once we head to invoice.
Browse files Browse the repository at this point in the history
Otherwise tests for hold_invoice fail on Travis (they use 180 / 2 as
the timeout, and we free it after 70 seconds).

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Dec 12, 2019
1 parent fb7c678 commit 2e97afd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lightningd/htlc_set.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <common/memleak.h>
#include <common/timeout.h>
#include <lightningd/htlc_end.h>
#include <lightningd/htlc_set.h>
Expand Down Expand Up @@ -84,10 +83,12 @@ static struct htlc_set *new_htlc_set(struct lightningd *ld,
* - SHOULD wait for at least 60 seconds after the initial
* HTLC.
*/
notleak(new_reltimer(ld->timers, set, time_from_sec(70),
timeout_htlc_set, set));
set->timeout = new_reltimer(ld->timers, set, time_from_sec(70),
timeout_htlc_set, set);
htlc_set_map_add(&ld->htlc_sets, set);
tal_add_destructor2(set, destroy_htlc_set, &ld->htlc_sets);
#else
set->timeout = NULL;
#endif
return set;
}
Expand Down Expand Up @@ -194,6 +195,8 @@ void htlc_set_add(struct lightningd *ld,
}

if (amount_msat_eq(set->so_far, total_msat)) {
/* Disable timer now, in case invoice_hook is slow! */
tal_free(set->timeout);
invoice_try_pay(ld, set, details);
return;
}
Expand Down
1 change: 1 addition & 0 deletions lightningd/htlc_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct htlc_set {
struct amount_msat total_msat, so_far;
struct sha256 payment_hash;
struct htlc_in **htlcs;
struct oneshot *timeout;
};

static inline const struct sha256 *keyof_htlc_set(const struct htlc_set *set)
Expand Down

0 comments on commit 2e97afd

Please sign in to comment.