diff options
| author | Garrett D'Amore <garrett@damore.org> | 2021-12-06 21:09:55 -0500 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2021-12-06 21:09:55 -0500 |
| commit | 037d26a902a3cd5016052c76a6747e40c1a0df50 (patch) | |
| tree | f76ed1eabcffa862d93ffe6ee3d53c6a0ae472c4 /src/core/stats.c | |
| parent | 21528dfe0998d056222191a4abe53d8d9f1286e3 (diff) | |
| download | nng-037d26a902a3cd5016052c76a6747e40c1a0df50.tar.gz nng-037d26a902a3cd5016052c76a6747e40c1a0df50.tar.bz2 nng-037d26a902a3cd5016052c76a6747e40c1a0df50.zip | |
ID map static initialization support.
This also arranges to clean up the maps at nng_fini time.
Diffstat (limited to 'src/core/stats.c')
| -rw-r--r-- | src/core/stats.c | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/src/core/stats.c b/src/core/stats.c index f7e52fb0..f9de055e 100644 --- a/src/core/stats.c +++ b/src/core/stats.c @@ -31,9 +31,19 @@ struct nng_stat { }; #ifdef NNG_ENABLE_STATS -static nni_stat_item stats_root; -static nni_mtx stats_lock = NNI_MTX_INITIALIZER; -static nni_mtx stats_val_lock = NNI_MTX_INITIALIZER; +static nni_stat_info stats_root_info = { + .si_name = "", + .si_desc = "all statistics", + .si_type = NNG_STAT_SCOPE, +}; + +static nni_stat_item stats_root = { + .si_children = NNI_LIST_INITIALIZER( + stats_root.si_children, nni_stat_item, si_node), + .si_info = &stats_root_info, +}; +static nni_mtx stats_lock = NNI_MTX_INITIALIZER; +static nni_mtx stats_val_lock = NNI_MTX_INITIALIZER; #endif void @@ -488,25 +498,6 @@ nng_stat_find_listener(nng_stat *stat, nng_listener l) return (nng_stat_find_scope(stat, "listener", nng_listener_id(l))); } -int -nni_stat_sys_init(void) -{ -#ifdef NNG_ENABLE_STATS - static const nni_stat_info root = { - .si_name = "", - .si_desc = "all statistics", - .si_type = NNG_STAT_SCOPE, - }; - nni_stat_init(&stats_root, &root); -#endif - return (0); -} - -void -nni_stat_sys_fini(void) -{ -} - #ifdef NNG_ENABLE_STATS void stat_sprint_scope(nni_stat *stat, char **scope, int *lenp) |
