diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-17 19:57:56 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-17 19:57:56 -0800 |
| commit | 5633a467a009945a4f1eb06f7ffe9f02b833567f (patch) | |
| tree | e0010755849424d1bc2b43940f537b5757052ebf /src/core/init.c | |
| parent | a00f1938497e629187ebc6035e03bb58d1017730 (diff) | |
| download | nng-5633a467a009945a4f1eb06f7ffe9f02b833567f.tar.gz nng-5633a467a009945a4f1eb06f7ffe9f02b833567f.tar.bz2 nng-5633a467a009945a4f1eb06f7ffe9f02b833567f.zip | |
Pipe IDs are now tracked on global ID hashes.
Diffstat (limited to 'src/core/init.c')
| -rw-r--r-- | src/core/init.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/core/init.c b/src/core/init.c index f10173c8..e0ce3bae 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -11,6 +11,12 @@ #include <stdlib.h> #include <stdio.h> +nni_idhash *nni_endpoints; +nni_idhash *nni_pipes; +nni_idhash *nni_sockets; +nni_mtx *nni_idlock; +static nni_mtx nni_idlock_x; + static int nni_init_helper(void) { @@ -19,6 +25,19 @@ nni_init_helper(void) if ((rv = nni_random_init()) != 0) { return (rv); } + 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)) { + nni_mtx_fini(&nni_idlock_x); + nni_random_fini(); + return (rv); + } + nni_idhash_set_limits(nni_pipes, 1, 0x7fffffff, + nni_random() & 0x7fffffff); + nni_idlock = &nni_idlock_x; nni_tran_init(); return (0); } @@ -34,6 +53,10 @@ nni_init(void) void nni_fini(void) { + nni_idhash_destroy(nni_endpoints); + nni_idhash_destroy(nni_pipes); + nni_idhash_destroy(nni_sockets); + nni_mtx_fini(&nni_idlock_x); nni_tran_fini(); nni_random_fini(); nni_plat_fini(); |
