diff options
Diffstat (limited to 'src/core/init.c')
| -rw-r--r-- | src/core/init.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/core/init.c b/src/core/init.c index 48a5096c..8ada0247 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -15,6 +15,10 @@ nni_idhash *nni_endpoints; nni_idhash *nni_pipes; nni_idhash *nni_sockets; nni_mtx *nni_idlock; + +static nni_idhash nni_endpoints_x; +static nni_idhash nni_pipes_x; +static nni_idhash nni_sockets_x; static nni_mtx nni_idlock_x; static int @@ -28,17 +32,23 @@ nni_init_helper(void) if ((rv = nni_mtx_init(&nni_idlock_x)) != 0) { return (rv); } - if (((rv = nni_idhash_create(&nni_endpoints)) != 0) || - ((rv = nni_idhash_create(&nni_pipes)) != 0) || - ((rv = nni_idhash_create(&nni_sockets)) != 0)) { + if (((rv = nni_idhash_init(&nni_endpoints_x)) != 0) || + ((rv = nni_idhash_init(&nni_pipes_x)) != 0) || + ((rv = nni_idhash_init(&nni_sockets_x)) != 0)) { nni_mtx_fini(&nni_idlock_x); nni_random_fini(); return (rv); } - nni_idhash_set_limits(nni_pipes, 1, 0x7fffffff, + nni_idhash_set_limits(&nni_pipes_x, 1, 0x7fffffff, nni_random() & 0x7fffffff); - nni_idhash_set_limits(nni_sockets, 1, 0xffffffff, 1); + nni_idhash_set_limits(&nni_sockets_x, 1, 0x7fffffff, 1); + nni_idhash_set_limits(&nni_endpoints_x, 1, 0xffffffff, 1); + nni_idlock = &nni_idlock_x; + nni_pipes = &nni_pipes_x; + nni_endpoints = &nni_endpoints_x; + nni_sockets = &nni_sockets_x; + nni_tran_init(); return (0); } @@ -54,9 +64,9 @@ nni_init(void) void nni_fini(void) { - nni_idhash_destroy(nni_endpoints); - nni_idhash_destroy(nni_pipes); - nni_idhash_destroy(nni_sockets); + nni_idhash_fini(&nni_endpoints_x); + nni_idhash_fini(&nni_pipes_x); + nni_idhash_fini(&nni_sockets_x); nni_mtx_fini(&nni_idlock_x); nni_tran_fini(); nni_random_fini(); |
