| 539 | } |
| 540 | |
| 541 | static struct command_result *list_done(struct command *cmd, |
| 542 | const char *method, |
| 543 | const char *buf, |
| 544 | const jsmntok_t *result, |
| 545 | struct per_subsystem *subsystem) |
| 546 | { |
| 547 | const struct subsystem_ops *ops = get_subsystem_ops(subsystem); |
| 548 | const jsmntok_t *t, *inv = json_get_member(buf, result, ops->arr_name); |
| 549 | size_t i; |
| 550 | u64 now = clock_time().ts.tv_sec; |
| 551 | |
| 552 | json_for_each_arr(i, t, inv) { |
| 553 | struct per_variant *variant; |
| 554 | u64 timestamp; |
| 555 | struct out_req *req; |
| 556 | |
| 557 | variant = ops->get_variant(buf, t, subsystem, ×tamp); |
| 558 | if (!variant) { |
| 559 | continue; |
| 560 | } |
| 561 | |
| 562 | /* Continue if we don't care. */ |
| 563 | if (variant->age == 0) { |
| 564 | continue; |
| 565 | } |
| 566 | |
| 567 | if (timestamp > now - variant->age) { |
| 568 | subsystem->num_uncleaned++; |
| 569 | continue; |
| 570 | } |
| 571 | |
| 572 | subsystem->cinfo->cleanup_reqs_remaining++; |
| 573 | req = jsonrpc_request_start(cmd, ops->del_command, |
| 574 | del_done, del_failed, variant); |
| 575 | ops->add_del_fields(req, buf, t); |
| 576 | send_outreq(req); |
| 577 | } |
| 578 | |
| 579 | subsystem->offset += max_entries_per_call; |
| 580 | return clean_finished_one(subsystem->cinfo); |
| 581 | } |
| 582 | |
| 583 | static struct command_result *list_failed(struct command *cmd, |
| 584 | const char *method, |
nothing calls this directly
no test coverage detected