From 5633a467a009945a4f1eb06f7ffe9f02b833567f Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 17 Jan 2017 19:57:56 -0800 Subject: Pipe IDs are now tracked on global ID hashes. --- src/core/init.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/core/init.c') 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 #include +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(); -- cgit v1.2.3-70-g09d2