mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
libplugin-pay: fix spurious leak reports.
1. The dijkstra can be temporary, doesn't need to last as long as pay cmd. 2. We fail multiple times in several places, so don't leak old failreason. 3. Make payments findable by our memleak detector. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -766,7 +766,7 @@ static struct route_hop *route(const tal_t *ctx,
|
|||||||
/* Try using disabled channels too */
|
/* Try using disabled channels too */
|
||||||
/* FIXME: is there somewhere we can annotate this for paystatus? */
|
/* FIXME: is there somewhere we can annotate this for paystatus? */
|
||||||
can_carry = payment_route_can_carry_even_disabled;
|
can_carry = payment_route_can_carry_even_disabled;
|
||||||
dij = dijkstra(ctx, gossmap, dst, amount, riskfactor,
|
dij = dijkstra(tmpctx, gossmap, dst, amount, riskfactor,
|
||||||
can_carry, route_score, p);
|
can_carry, route_score, p);
|
||||||
r = route_from_dijkstra(ctx, gossmap, dij, src,
|
r = route_from_dijkstra(ctx, gossmap, dij, src,
|
||||||
amount, final_delay);
|
amount, final_delay);
|
||||||
@@ -2122,6 +2122,8 @@ void payment_abort(struct payment *p, const char *fmt, ...) {
|
|||||||
payment_set_step(p, PAYMENT_STEP_FAILED);
|
payment_set_step(p, PAYMENT_STEP_FAILED);
|
||||||
p->end_time = time_now();
|
p->end_time = time_now();
|
||||||
|
|
||||||
|
/* We can fail twice, it seems. */
|
||||||
|
tal_free(p->failreason);
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
p->failreason = tal_vfmt(p, fmt, ap);
|
p->failreason = tal_vfmt(p, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
@@ -2147,6 +2149,8 @@ void payment_fail(struct payment *p, const char *fmt, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
p->end_time = time_now();
|
p->end_time = time_now();
|
||||||
payment_set_step(p, PAYMENT_STEP_FAILED);
|
payment_set_step(p, PAYMENT_STEP_FAILED);
|
||||||
|
/* We can fail twice, it seems. */
|
||||||
|
tal_free(p->failreason);
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
p->failreason = tal_vfmt(p, fmt, ap);
|
p->failreason = tal_vfmt(p, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|||||||
@@ -160,11 +160,12 @@ struct payment_constraints {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct payment {
|
struct payment {
|
||||||
|
/* Usually in global payments list */
|
||||||
|
struct list_node list;
|
||||||
/* The command that triggered this payment. Only set for the root
|
/* The command that triggered this payment. Only set for the root
|
||||||
* payment. */
|
* payment. */
|
||||||
struct command *cmd;
|
struct command *cmd;
|
||||||
struct plugin *plugin;
|
struct plugin *plugin;
|
||||||
struct list_node list;
|
|
||||||
struct node_id *local_id;
|
struct node_id *local_id;
|
||||||
|
|
||||||
const char *json_buffer;
|
const char *json_buffer;
|
||||||
|
|||||||
Reference in New Issue
Block a user