From 2e97afd1ac9184b32f0ac5193b325584cddf2323 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 12 Dec 2019 21:26:07 +1030 Subject: [PATCH] lightningd: remove htlc_set destruction timer once we head to invoice. 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 --- lightningd/htlc_set.c | 9 ++++++--- lightningd/htlc_set.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lightningd/htlc_set.c b/lightningd/htlc_set.c index dced43782..260e0873e 100644 --- a/lightningd/htlc_set.c +++ b/lightningd/htlc_set.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -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; } @@ -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; } diff --git a/lightningd/htlc_set.h b/lightningd/htlc_set.h index 11e57adcb..264a52a7b 100644 --- a/lightningd/htlc_set.h +++ b/lightningd/htlc_set.h @@ -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)