@@ -1346,6 +1346,7 @@ static bool check_htlc_max_limits(struct route_query *rq, struct flow **flows)
13461346 */
13471347static const char *
13481348linear_routes (const tal_t * ctx , struct route_query * rq ,
1349+ struct timemono deadline ,
13491350 const struct gossmap_node * srcnode ,
13501351 const struct gossmap_node * dstnode , struct amount_msat amount ,
13511352 struct amount_msat maxfee , u32 finalcltv , u32 maxdelay ,
@@ -1379,6 +1380,13 @@ linear_routes(const tal_t *ctx, struct route_query *rq,
13791380 size_t num_parts , parts_slots , excess_parts ;
13801381 u32 bottleneck_idx ;
13811382
1383+ if (timemono_after (time_mono (), deadline )) {
1384+ error_message = rq_log (ctx , rq , LOG_BROKEN ,
1385+ "%s: timed out after deadline" ,
1386+ __func__ );
1387+ goto fail ;
1388+ }
1389+
13821390 /* FIXME: This algorithm to limit the number of parts is dumb
13831391 * for two reasons:
13841392 * 1. it does not take into account that several loop
@@ -1641,25 +1649,27 @@ linear_routes(const tal_t *ctx, struct route_query *rq,
16411649}
16421650
16431651const char * default_routes (const tal_t * ctx , struct route_query * rq ,
1652+ struct timemono deadline ,
16441653 const struct gossmap_node * srcnode ,
16451654 const struct gossmap_node * dstnode ,
16461655 struct amount_msat amount , struct amount_msat maxfee ,
16471656 u32 finalcltv , u32 maxdelay , struct flow * * * flows ,
16481657 double * probability )
16491658{
1650- return linear_routes (ctx , rq , srcnode , dstnode , amount , maxfee ,
1659+ return linear_routes (ctx , rq , deadline , srcnode , dstnode , amount , maxfee ,
16511660 finalcltv , maxdelay , flows , probability , minflow );
16521661}
16531662
16541663const char * single_path_routes (const tal_t * ctx , struct route_query * rq ,
1664+ struct timemono deadline ,
16551665 const struct gossmap_node * srcnode ,
16561666 const struct gossmap_node * dstnode ,
16571667 struct amount_msat amount ,
16581668 struct amount_msat maxfee , u32 finalcltv ,
16591669 u32 maxdelay , struct flow * * * flows ,
16601670 double * probability )
16611671{
1662- return linear_routes (ctx , rq , srcnode , dstnode , amount , maxfee ,
1672+ return linear_routes (ctx , rq , deadline , srcnode , dstnode , amount , maxfee ,
16631673 finalcltv , maxdelay , flows , probability ,
16641674 single_path_flow );
16651675}
0 commit comments