diff options
author | Andrew Clayton <a.clayton@nginx.com> | 2024-06-26 23:52:43 +0100 |
---|---|---|
committer | Andrew Clayton <a.clayton@nginx.com> | 2024-07-12 16:44:54 +0100 |
commit | c8d70c3ff28bcf18dfbcfa1332ce0f0d869c0d5f (patch) | |
tree | 3f71104c012dedd4896a101779e3a8c93c9656d8 /src | |
parent | 081e51151efc7976f578692ee9fc23df14b35a6e (diff) | |
download | unit-c8d70c3ff28bcf18dfbcfa1332ce0f0d869c0d5f.tar.gz unit-c8d70c3ff28bcf18dfbcfa1332ce0f0d869c0d5f.tar.bz2 |
status: Use a variable to represent the status member index
In nxt_status_get() call nxt_conf_set_member() multiple times to set the
main /status json sections.
Previously this used hard coded values, 0, 1, 2 etc, if you wanted to
change the order or insert new sections it could mean renumbering all
these.
Instead use a variable to track this index which starts at 0 and is
simply incremented in each call of nxt_conf_set_member().
Currently this is only for the main outer sections, but can be
replicated for inner sections if required.
This is a preparatory patch for adding a new "modules" section at the
top.
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/nxt_status.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nxt_status.c b/src/nxt_status.c index 0635f0b2..957bc34e 100644 --- a/src/nxt_status.c +++ b/src/nxt_status.c @@ -12,6 +12,7 @@ nxt_conf_value_t * nxt_status_get(nxt_status_report_t *report, nxt_mp_t *mp) { size_t i; + uint32_t idx = 0; nxt_str_t name; nxt_int_t ret; nxt_status_app_t *app; @@ -39,7 +40,7 @@ nxt_status_get(nxt_status_report_t *report, nxt_mp_t *mp) return NULL; } - nxt_conf_set_member(status, &conns_str, obj, 0); + nxt_conf_set_member(status, &conns_str, obj, idx++); nxt_conf_set_member_integer(obj, &acc_str, report->accepted_conns, 0); nxt_conf_set_member_integer(obj, &active_str, report->accepted_conns @@ -53,7 +54,7 @@ nxt_status_get(nxt_status_report_t *report, nxt_mp_t *mp) return NULL; } - nxt_conf_set_member(status, &reqs_str, obj, 1); + nxt_conf_set_member(status, &reqs_str, obj, idx++); nxt_conf_set_member_integer(obj, &total_str, report->requests, 0); @@ -62,7 +63,7 @@ nxt_status_get(nxt_status_report_t *report, nxt_mp_t *mp) return NULL; } - nxt_conf_set_member(status, &apps_str, apps, 2); + nxt_conf_set_member(status, &apps_str, apps, idx++); for (i = 0; i < report->apps_count; i++) { app = &report->apps[i]; |