| 499 | } |
| 500 | |
| 501 | void md_status_take_stock(md_json_t **pjson, apr_array_header_t *mds, |
| 502 | md_reg_t *reg, apr_pool_t *p) |
| 503 | { |
| 504 | const md_t *md; |
| 505 | md_job_t *job; |
| 506 | int i, complete, renewing, errored, ready, total; |
| 507 | md_json_t *json; |
| 508 | |
| 509 | json = md_json_create(p); |
| 510 | complete = renewing = errored = ready = total = 0; |
| 511 | for (i = 0; i < mds->nelts; ++i) { |
| 512 | md = APR_ARRAY_IDX(mds, i, const md_t *); |
| 513 | ++total; |
| 514 | switch (md->state) { |
| 515 | case MD_S_COMPLETE: ++complete; /* fall through */ |
| 516 | case MD_S_INCOMPLETE: |
| 517 | if (md_reg_should_renew(reg, md, p)) { |
| 518 | ++renewing; |
| 519 | job = md_reg_job_make(reg, md->name, p); |
| 520 | if (APR_SUCCESS == md_job_load(job)) { |
| 521 | if (job->error_runs > 0 |
| 522 | || (job->last_result && job->last_result->status != APR_SUCCESS)) { |
| 523 | ++errored; |
| 524 | } |
| 525 | else if (job->finished) { |
| 526 | ++ready; |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | break; |
| 531 | default: ++errored; break; |
| 532 | } |
| 533 | } |
| 534 | md_json_setl(total, json, MD_KEY_TOTAL, NULL); |
| 535 | md_json_setl(complete, json, MD_KEY_COMPLETE, NULL); |
| 536 | md_json_setl(renewing, json, MD_KEY_RENEWING, NULL); |
| 537 | md_json_setl(errored, json, MD_KEY_ERRORED, NULL); |
| 538 | md_json_setl(ready, json, MD_KEY_READY, NULL); |
| 539 | *pjson = json; |
| 540 | } |
| 541 | |
| 542 | typedef struct { |
| 543 | apr_pool_t *p; |
no test coverage detected