Browse Source

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 <rusty@rustcorp.com.au>
travis-debug
Rusty Russell 5 years ago
committed by Christian Decker
parent
commit
2e97afd1ac
  1. 9
      lightningd/htlc_set.c
  2. 1
      lightningd/htlc_set.h

9
lightningd/htlc_set.c

@ -1,4 +1,3 @@
#include <common/memleak.h>
#include <common/timeout.h> #include <common/timeout.h>
#include <lightningd/htlc_end.h> #include <lightningd/htlc_end.h>
#include <lightningd/htlc_set.h> #include <lightningd/htlc_set.h>
@ -84,10 +83,12 @@ static struct htlc_set *new_htlc_set(struct lightningd *ld,
* - SHOULD wait for at least 60 seconds after the initial * - SHOULD wait for at least 60 seconds after the initial
* HTLC. * HTLC.
*/ */
notleak(new_reltimer(ld->timers, set, time_from_sec(70), set->timeout = new_reltimer(ld->timers, set, time_from_sec(70),
timeout_htlc_set, set)); timeout_htlc_set, set);
htlc_set_map_add(&ld->htlc_sets, set); htlc_set_map_add(&ld->htlc_sets, set);
tal_add_destructor2(set, destroy_htlc_set, &ld->htlc_sets); tal_add_destructor2(set, destroy_htlc_set, &ld->htlc_sets);
#else
set->timeout = NULL;
#endif #endif
return set; return set;
} }
@ -194,6 +195,8 @@ void htlc_set_add(struct lightningd *ld,
} }
if (amount_msat_eq(set->so_far, total_msat)) { 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); invoice_try_pay(ld, set, details);
return; return;
} }

1
lightningd/htlc_set.h

@ -17,6 +17,7 @@ struct htlc_set {
struct amount_msat total_msat, so_far; struct amount_msat total_msat, so_far;
struct sha256 payment_hash; struct sha256 payment_hash;
struct htlc_in **htlcs; struct htlc_in **htlcs;
struct oneshot *timeout;
}; };
static inline const struct sha256 *keyof_htlc_set(const struct htlc_set *set) static inline const struct sha256 *keyof_htlc_set(const struct htlc_set *set)

Loading…
Cancel
Save