diff options
-rw-r--r-- | mwrap_httpd.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/mwrap_httpd.h b/mwrap_httpd.h index bd37fb2..aa4574a 100644 --- a/mwrap_httpd.h +++ b/mwrap_httpd.h @@ -487,6 +487,13 @@ static struct h1_src_loc *accumulate(unsigned long min, size_t *hslc, FILE *lp) return hslv; } +static void show_age(FILE *fp) +{ + size_t dec = uatomic_read(&total_bytes_dec); + size_t inc = uatomic_read(&total_bytes_inc); + fprintf(fp, "<p>Current age: %zu (live: %zu)", inc , inc - dec); +} + /* /$PID/at/$LOCATION endpoint */ static enum mw_qev each_at(struct mw_h1 *h1, struct mw_h1req *h1r) { @@ -519,9 +526,7 @@ static enum mw_qev each_at(struct mw_h1 *h1, struct mw_h1req *h1r) write_html(fp, lname.ptr, lname.len); free(lname.ptr); - size_t age = uatomic_read(&total_bytes_inc); - fprintf(fp, "<p>Current age: %zu (live: %zu)", - age, age - uatomic_read(&total_bytes_dec)); + show_age(fp); FPUTS("<table><tr><th>size</th><th>generation</th>" "<th>address</th></tr>", fp); @@ -580,10 +585,8 @@ static enum mw_qev each_gt(struct mw_h1 *h1, struct mw_h1req *h1r, fprintf(fp, "<html><head><title>mwrap each >%lu" "</title></head><body><p>mwrap each >%lu " "(change `%lu' in URL to adjust filtering)", min, min, min); - size_t age = uatomic_read(&total_bytes_inc); - fprintf(fp, "<p>Current age: %zu (live: %zu)", - age, age - uatomic_read(&total_bytes_dec)); + show_age(fp); if (bt_req_depth) /* need borders to distinguish multi-level traces */ FPUTS("<table\nborder=1><tr>", fp); else /* save screen space if only tracing one line */ |