aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-06-09 06:36:19 -0700
committerGarrett D'Amore <garrett@damore.org>2017-06-09 06:36:19 -0700
commitc50111c825d2a6724ea49ea72cee0eeb420ec432 (patch)
tree0cf8aeb3113b6bf4861b0420212383df480a0237 /src/core
parent4044f93afb21f2a5700eb312f1daa6e2a0152ab6 (diff)
downloadnng-c50111c825d2a6724ea49ea72cee0eeb420ec432.tar.gz
nng-c50111c825d2a6724ea49ea72cee0eeb420ec432.tar.bz2
nng-c50111c825d2a6724ea49ea72cee0eeb420ec432.zip
Eliminate pipes global idhash.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/init.c33
-rw-r--r--src/core/init.h5
-rw-r--r--src/core/pipe.c24
3 files changed, 12 insertions, 50 deletions
diff --git a/src/core/init.c b/src/core/init.c
index 3339b532..c2fe3aff 100644
--- a/src/core/init.c
+++ b/src/core/init.c
@@ -11,12 +11,6 @@
#include <stdlib.h>
#include <stdio.h>
-nni_idhash *nni_pipes;
-nni_mtx *nni_idlock;
-
-static nni_idhash nni_pipes_x;
-static nni_mtx nni_idlock_x;
-
static int
nni_init_helper(void)
{
@@ -55,31 +49,6 @@ nni_init_helper(void)
nni_taskq_sys_fini();
return (rv);
}
- if ((rv = nni_mtx_init(&nni_idlock_x)) != 0) {
- nni_pipe_sys_fini();
- nni_ep_sys_fini();
- nni_sock_sys_fini();
- nni_random_sys_fini();
- nni_timer_sys_fini();
- nni_taskq_sys_fini();
- return (rv);
- }
- if ((rv = nni_idhash_init(&nni_pipes_x)) != 0) {
- nni_mtx_fini(&nni_idlock_x);
- nni_pipe_sys_fini();
- nni_ep_sys_fini();
- nni_sock_sys_fini();
- nni_random_sys_fini();
- nni_timer_sys_fini();
- nni_taskq_sys_fini();
- return (rv);
- }
- nni_idhash_set_limits(&nni_pipes_x, 1, 0x7fffffff,
- (nni_random() & 0x7ffffffe) + 1);
-
- nni_idlock = &nni_idlock_x;
- nni_pipes = &nni_pipes_x;
-
nni_tran_sys_init();
return (0);
}
@@ -95,8 +64,6 @@ nni_init(void)
void
nni_fini(void)
{
- nni_idhash_fini(&nni_pipes_x);
- nni_mtx_fini(&nni_idlock_x);
nni_tran_sys_fini();
nni_ep_sys_fini();
nni_sock_sys_fini();
diff --git a/src/core/init.h b/src/core/init.h
index 70663c65..ffcebf64 100644
--- a/src/core/init.h
+++ b/src/core/init.h
@@ -21,9 +21,4 @@ int nni_init(void);
// that all resources used by the library are released back to the system.
void nni_fini(void);
-// Private hash tables matching IDs to values. Consumers need to use the
-// nni_idlock to protect access to these.
-extern nni_mtx *nni_idlock;
-extern nni_idhash *nni_pipes;
-
#endif // CORE_INIT_H
diff --git a/src/core/pipe.c b/src/core/pipe.c
index dd597feb..58703814 100644
--- a/src/core/pipe.c
+++ b/src/core/pipe.c
@@ -14,7 +14,7 @@
// Operations on pipes (to the transport) are generally blocking operations,
// performed in the context of the protocol.
-static nni_objhash *nni_allpipes;
+static nni_objhash *nni_pipes;
static void *
nni_pipe_ctor(uint32_t id)
@@ -61,7 +61,7 @@ nni_pipe_sys_init(void)
{
int rv;
- rv = nni_objhash_init(&nni_allpipes, nni_pipe_ctor, nni_pipe_dtor);
+ rv = nni_objhash_init(&nni_pipes, nni_pipe_ctor, nni_pipe_dtor);
if (rv != 0) {
return (rv);
@@ -74,8 +74,8 @@ nni_pipe_sys_init(void)
void
nni_pipe_sys_fini(void)
{
- nni_objhash_fini(nni_allpipes);
- nni_allpipes = NULL;
+ nni_objhash_fini(nni_pipes);
+ nni_pipes = NULL;
}
@@ -107,7 +107,7 @@ nni_pipe_incref(nni_pipe *p)
int rv;
nni_pipe *scratch;
- rv = nni_objhash_find(nni_allpipes, p->p_id, (void **) &scratch);
+ rv = nni_objhash_find(nni_pipes, p->p_id, (void **) &scratch);
NNI_ASSERT(rv == 0);
NNI_ASSERT(p == scratch);
}
@@ -116,7 +116,7 @@ nni_pipe_incref(nni_pipe *p)
void
nni_pipe_decref(nni_pipe *p)
{
- nni_objhash_unref(nni_allpipes, p->p_id);
+ nni_objhash_unref(nni_pipes, p->p_id);
}
@@ -146,7 +146,7 @@ nni_pipe_close(nni_pipe *p)
// Let the socket (and endpoint) know we have closed.
nni_sock_pipe_closed(sock, p);
- nni_objhash_unref(nni_allpipes, p->p_id);
+ nni_objhash_unref(nni_pipes, p->p_id);
}
@@ -164,7 +164,7 @@ nni_pipe_create(nni_pipe **pp, nni_ep *ep, nni_sock *sock, nni_tran *tran)
int rv;
uint32_t id;
- rv = nni_objhash_alloc(nni_allpipes, &id, (void **) &p);
+ rv = nni_objhash_alloc(nni_pipes, &id, (void **) &p);
if (rv != 0) {
return (rv);
}
@@ -176,12 +176,12 @@ nni_pipe_create(nni_pipe **pp, nni_ep *ep, nni_sock *sock, nni_tran *tran)
// Initialize the transport pipe data.
if ((rv = p->p_tran_ops.p_init(&p->p_tran_data)) != 0) {
- nni_objhash_unref(nni_allpipes, p->p_id);
+ nni_objhash_unref(nni_pipes, p->p_id);
return (rv);
}
if ((rv = nni_sock_pipe_add(sock, p)) != 0) {
- nni_objhash_unref(nni_allpipes, p->p_id);
+ nni_objhash_unref(nni_pipes, p->p_id);
return (rv);
}
@@ -195,7 +195,7 @@ nni_pipe_destroy(nni_pipe *p)
{
NNI_ASSERT(p->p_refcnt == 0);
- nni_objhash_unref(nni_allpipes, p->p_id);
+ nni_objhash_unref(nni_pipes, p->p_id);
}
@@ -216,7 +216,7 @@ nni_pipe_start(nni_pipe *p)
int rv;
nni_pipe *scratch;
- rv = nni_objhash_find(nni_allpipes, p->p_id, (void **) &scratch);
+ rv = nni_objhash_find(nni_pipes, p->p_id, (void **) &scratch);
if (rv != 0) {
return (rv);
}