diff options
Diffstat (limited to 'src/core/pipe.c')
| -rw-r--r-- | src/core/pipe.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/core/pipe.c b/src/core/pipe.c index d673f7c4..ce24e28e 100644 --- a/src/core/pipe.c +++ b/src/core/pipe.c @@ -25,14 +25,14 @@ nni_pipe_id(nni_pipe *p) int nni_pipe_send(nni_pipe *p, nng_msg *msg) { - return (p->p_tran_ops.p_send(p->p_tran_data, msg)); + return (p->p_tran_ops.pipe_send(p->p_tran_data, msg)); } int nni_pipe_recv(nni_pipe *p, nng_msg **msgp) { - return (p->p_tran_ops.p_recv(p->p_tran_data, msgp)); + return (p->p_tran_ops.pipe_recv(p->p_tran_data, msgp)); } @@ -45,7 +45,7 @@ nni_pipe_close(nni_pipe *p) nni_sock *sock = p->p_sock; if (p->p_tran_data != NULL) { - p->p_tran_ops.p_close(p->p_tran_data); + p->p_tran_ops.pipe_close(p->p_tran_data); } nni_mtx_lock(&sock->s_mx); @@ -63,7 +63,7 @@ nni_pipe_close(nni_pipe *p) uint16_t nni_pipe_peer(nni_pipe *p) { - return (p->p_tran_ops.p_peer(p->p_tran_data)); + return (p->p_tran_ops.pipe_peer(p->p_tran_data)); } @@ -74,7 +74,7 @@ nni_pipe_destroy(nni_pipe *p) nni_thr_fini(&p->p_recv_thr); if (p->p_tran_data != NULL) { - p->p_tran_ops.p_destroy(p->p_tran_data); + p->p_tran_ops.pipe_destroy(p->p_tran_data); } if (p->p_pdata != NULL) { nni_free(p->p_pdata, p->p_psize); @@ -95,12 +95,15 @@ nni_pipe_create(nni_pipe **pp, nni_endpt *ep) return (NNG_ENOMEM); } p->p_sock = sock; - p->p_tran_ops = *ep->ep_ops.ep_pipe_ops; p->p_tran_data = NULL; p->p_active = 0; p->p_psize = proto->proto_pipe_size; NNI_LIST_NODE_INIT(&p->p_node); + // Make a copy of the transport ops. We can override entry points + // and we avoid an extra dereference on hot code paths. + p->p_tran_ops = *ep->ep_tran->tran_pipe; + if ((p->p_pdata = nni_alloc(p->p_psize)) == NULL) { NNI_FREE_STRUCT(p); return (NNG_ENOMEM); @@ -132,10 +135,10 @@ int nni_pipe_getopt(nni_pipe *p, int opt, void *val, size_t *szp) { /* This should only be called with the mutex held... */ - if (p->p_tran_ops.p_getopt == NULL) { + if (p->p_tran_ops.pipe_getopt == NULL) { return (NNG_ENOTSUP); } - return (p->p_tran_ops.p_getopt(p->p_tran_data, opt, val, szp)); + return (p->p_tran_ops.pipe_getopt(p->p_tran_data, opt, val, szp)); } |
