summaryrefslogtreecommitdiff
path: root/src/protocol
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-07-13 18:17:02 -0700
committerGarrett D'Amore <garrett@damore.org>2017-07-13 18:17:02 -0700
commit14caa074a83fa2e659b3e490bf9bd31ff0b6b4b1 (patch)
treea393024cc23b7540fa08009b221e3e40a195603d /src/protocol
parent722cd0deed891bfcb3f1e9866655cc5a41b2111e (diff)
downloadnng-14caa074a83fa2e659b3e490bf9bd31ff0b6b4b1.tar.gz
nng-14caa074a83fa2e659b3e490bf9bd31ff0b6b4b1.tar.bz2
nng-14caa074a83fa2e659b3e490bf9bd31ff0b6b4b1.zip
Make idhash non-inlined (so we can add a mutex.)
Diffstat (limited to 'src/protocol')
-rw-r--r--src/protocol/reqrep/rep.c29
-rw-r--r--src/protocol/survey/respond.c29
2 files changed, 30 insertions, 28 deletions
diff --git a/src/protocol/reqrep/rep.c b/src/protocol/reqrep/rep.c
index cfc83a5b..d37ca691 100644
--- a/src/protocol/reqrep/rep.c
+++ b/src/protocol/reqrep/rep.c
@@ -1,5 +1,6 @@
//
// Copyright 2017 Garrett D'Amore <garrett@damore.org>
+// Copyright 2017 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -28,16 +29,16 @@ static void nni_rep_pipe_fini(void *);
// An nni_rep_sock is our per-socket protocol private structure.
struct nni_rep_sock {
- nni_sock * sock;
- nni_msgq * uwq;
- nni_msgq * urq;
- int raw;
- int ttl;
- nni_idhash pipes;
- char * btrace;
- size_t btrace_len;
- nni_aio aio_getq;
- nni_mtx mtx;
+ nni_sock * sock;
+ nni_msgq * uwq;
+ nni_msgq * urq;
+ int raw;
+ int ttl;
+ nni_idhash *pipes;
+ char * btrace;
+ size_t btrace_len;
+ nni_aio aio_getq;
+ nni_mtx mtx;
};
// An nni_rep_pipe is our per-pipe protocol private structure.
@@ -59,7 +60,7 @@ nni_rep_sock_fini(void *arg)
nni_rep_sock *rep = arg;
nni_aio_fini(&rep->aio_getq);
- nni_idhash_fini(&rep->pipes);
+ nni_idhash_fini(rep->pipes);
if (rep->btrace != NULL) {
nni_free(rep->btrace, rep->btrace_len);
}
@@ -183,7 +184,7 @@ nni_rep_pipe_start(void *arg)
rp->id = nni_pipe_id(rp->pipe);
nni_mtx_lock(&rep->mtx);
- rv = nni_idhash_insert(&rep->pipes, rp->id, rp);
+ rv = nni_idhash_insert(rep->pipes, rp->id, rp);
nni_mtx_unlock(&rep->mtx);
if (rv != 0) {
return (rv);
@@ -214,7 +215,7 @@ nni_rep_pipe_stop(void *arg)
if (id != 0) {
nni_mtx_lock(&rep->mtx);
- nni_idhash_remove(&rep->pipes, id);
+ nni_idhash_remove(rep->pipes, id);
nni_mtx_unlock(&rep->mtx);
}
}
@@ -260,7 +261,7 @@ nni_rep_sock_getq_cb(void *arg)
// (nonblocking) if we can. If we can't for any reason, then we
// free the message.
nni_mtx_lock(&rep->mtx);
- rv = nni_idhash_find(&rep->pipes, id, (void **) &rp);
+ rv = nni_idhash_find(rep->pipes, id, (void **) &rp);
nni_mtx_unlock(&rep->mtx);
if (rv == 0) {
rv = nni_msgq_tryput(rp->sendq, msg);
diff --git a/src/protocol/survey/respond.c b/src/protocol/survey/respond.c
index 6a784738..17018155 100644
--- a/src/protocol/survey/respond.c
+++ b/src/protocol/survey/respond.c
@@ -1,5 +1,6 @@
//
// Copyright 2017 Garrett D'Amore <garrett@damore.org>
+// Copyright 2017 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -28,16 +29,16 @@ static void nni_resp_pipe_fini(void *);
// An nni_resp_sock is our per-socket protocol private structure.
struct nni_resp_sock {
- nni_sock * nsock;
- nni_msgq * urq;
- nni_msgq * uwq;
- int raw;
- int ttl;
- nni_idhash pipes;
- char * btrace;
- size_t btrace_len;
- nni_aio aio_getq;
- nni_mtx mtx;
+ nni_sock * nsock;
+ nni_msgq * urq;
+ nni_msgq * uwq;
+ int raw;
+ int ttl;
+ nni_idhash *pipes;
+ char * btrace;
+ size_t btrace_len;
+ nni_aio aio_getq;
+ nni_mtx mtx;
};
// An nni_resp_pipe is our per-pipe protocol private structure.
@@ -59,7 +60,7 @@ nni_resp_sock_fini(void *arg)
if (psock != NULL) {
nni_aio_fini(&psock->aio_getq);
- nni_idhash_fini(&psock->pipes);
+ nni_idhash_fini(psock->pipes);
if (psock->btrace != NULL) {
nni_free(psock->btrace, psock->btrace_len);
}
@@ -180,7 +181,7 @@ nni_resp_pipe_start(void *arg)
ppipe->id = nni_pipe_id(ppipe->npipe);
nni_mtx_lock(&psock->mtx);
- rv = nni_idhash_insert(&psock->pipes, ppipe->id, ppipe);
+ rv = nni_idhash_insert(psock->pipes, ppipe->id, ppipe);
nni_mtx_unlock(&psock->mtx);
if (rv != 0) {
return (rv);
@@ -206,7 +207,7 @@ nni_resp_pipe_stop(void *arg)
nni_mtx_lock(&psock->mtx);
if (ppipe->id != 0) {
- nni_idhash_remove(&psock->pipes, ppipe->id);
+ nni_idhash_remove(psock->pipes, ppipe->id);
ppipe->id = 0;
}
nni_mtx_unlock(&psock->mtx);
@@ -246,7 +247,7 @@ nni_resp_sock_getq_cb(void *arg)
nni_msg_trim_header(msg, 4);
nni_mtx_lock(&psock->mtx);
- rv = nni_idhash_find(&psock->pipes, id, (void **) &ppipe);
+ rv = nni_idhash_find(psock->pipes, id, (void **) &ppipe);
if (rv != 0) {
nni_msg_free(msg);