payalgo: Report reason to delay before clearing try memory.

We allocate the reason to delay, if any, from the `pay->try_parent`.
So we should not clear the `pay->try_parent` until after we print
the reason.
This commit is contained in:
ZmnSCPxj 2018-05-07 14:19:51 +00:00 committed by Rusty Russell
parent 104645ba3a
commit c79b3de4d6

View File

@ -344,12 +344,13 @@ static void json_pay_sendpay_resolve(const struct sendpay_result *r,
if (why) {
/* We have some reason to delay retrying. */
log_info(pay->cmd->ld->log,
"pay(%p): Delay before retry: %s", pay, why);
/* Clear previous try memory. */
pay->try_parent = tal_free(pay->try_parent);
pay->try_parent = tal(pay, char);
log_info(pay->cmd->ld->log,
"pay(%p): Delay before retry: %s", pay, why);
/* Delay for 3 seconds if needed. FIXME: random
* exponential backoff */
new_reltimer(&pay->cmd->ld->timers, pay->try_parent,