Recursion */
| 567 | |
| 568 | /* Recursion */ |
| 569 | static struct command_result *one_refresh_done(struct command *cmd, |
| 570 | struct db_query *dbq, |
| 571 | bool was_limited) |
| 572 | { |
| 573 | struct table_desc *td = dbq->tables[0]; |
| 574 | struct list_head waiters; |
| 575 | struct refresh_waiter *rw; |
| 576 | struct timerel refresh_duration = timemono_since(td->refresh_start); |
| 577 | |
| 578 | /* If we may have more, keep going. */ |
| 579 | if (was_limited) |
| 580 | return td->refresh(cmd, dbq->tables[0], dbq); |
| 581 | |
| 582 | /* We are no longer refreshing */ |
| 583 | assert(td->refreshing); |
| 584 | td->refreshing = false; |
| 585 | plugin_log(cmd->plugin, LOG_DBG, |
| 586 | "Time to refresh %s: %"PRIu64".%09"PRIu64" seconds (last=%"PRIu64")", |
| 587 | td->name, |
| 588 | (u64)refresh_duration.ts.tv_sec, |
| 589 | (u64)refresh_duration.ts.tv_nsec, |
| 590 | td->last_created_index); |
| 591 | |
| 592 | if (!td->populated) { |
| 593 | /* Now we've done initial population, install indices: |
| 594 | * much faster than creating them before! */ |
| 595 | init_indices(cmd->plugin, td); |
| 596 | td->populated = true; |
| 597 | refresh_duration = timemono_since(td->refresh_start); |
| 598 | plugin_log(cmd->plugin, LOG_DBG, |
| 599 | "Time to refresh + create indices for %s: %"PRIu64".%09"PRIu64" seconds", |
| 600 | td->name, |
| 601 | (u64)refresh_duration.ts.tv_sec, |
| 602 | (u64)refresh_duration.ts.tv_nsec); |
| 603 | } |
| 604 | |
| 605 | /* Transfer refresh waiters onto local list */ |
| 606 | list_head_init(&waiters); |
| 607 | list_append_list(&waiters, &td->refresh_waiters); |
| 608 | |
| 609 | while ((rw = list_pop(&waiters, struct refresh_waiter, list)) != NULL) { |
| 610 | struct command *rwcmd = rw->cmd; |
| 611 | struct db_query *rwdbq = rw->dbq; |
| 612 | tal_free(rw); |
| 613 | |
| 614 | /* Remove that one, and refresh the rest */ |
| 615 | assert(rwdbq->tables[0] == td); |
| 616 | tal_arr_remove(&rwdbq->tables, 0); |
| 617 | refresh_tables(rwcmd, rwdbq); |
| 618 | } |
| 619 | return next_refresh(cmd, dbq); |
| 620 | } |
| 621 | |
| 622 | /* Mutual recursion */ |
| 623 | static struct command_result *process_json_list(struct command *cmd, |
no test coverage detected