diff options
| -rw-r--r-- | src/core/endpt.c | 4 | ||||
| -rw-r--r-- | src/core/endpt.h | 2 | ||||
| -rw-r--r-- | src/core/pipe.c | 14 | ||||
| -rw-r--r-- | src/core/pipe.h | 9 | ||||
| -rw-r--r-- | src/core/transport.h | 10 | ||||
| -rw-r--r-- | src/transport/inproc/inproc.c | 8 | ||||
| -rw-r--r-- | src/transport/ipc/ipc.c | 8 | ||||
| -rw-r--r-- | src/transport/tcp/tcp.c | 8 |
8 files changed, 42 insertions, 21 deletions
diff --git a/src/core/endpt.c b/src/core/endpt.c index b5ec0ced..0310783a 100644 --- a/src/core/endpt.c +++ b/src/core/endpt.c @@ -207,7 +207,7 @@ nni_ep_connect(nni_ep *ep, nni_pipe **pp) if ((rv = nni_pipe_create(&pipe, ep, ep->ep_sock, ep->ep_tran)) != 0) { return (rv); } - rv = ep->ep_ops.ep_connect(ep->ep_data, &pipe->p_tran_data); + rv = ep->ep_ops.ep_connect(ep->ep_data, pipe); if (rv != 0) { nni_pipe_destroy(pipe); return (rv); @@ -359,7 +359,7 @@ nni_ep_accept(nni_ep *ep, nni_pipe **pp) if ((rv = nni_pipe_create(&pipe, ep, ep->ep_sock, ep->ep_tran)) != 0) { return (rv); } - rv = ep->ep_ops.ep_accept(ep->ep_data, &pipe->p_tran_data); + rv = ep->ep_ops.ep_accept(ep->ep_data, pipe); if (rv != 0) { nni_pipe_destroy(pipe); return (rv); diff --git a/src/core/endpt.h b/src/core/endpt.h index 6230ca9f..dbd9ec42 100644 --- a/src/core/endpt.h +++ b/src/core/endpt.h @@ -31,7 +31,7 @@ struct nni_ep { int ep_close; // full shutdown int ep_bound; // true if we bound locally nni_cv ep_cv; - int ep_holds; // user references (by id) + int ep_holds; // user references (by id) nni_cv ep_holdcv; nni_pipe * ep_pipe; // Connected pipe (dialers only) }; diff --git a/src/core/pipe.c b/src/core/pipe.c index 8eb6c376..85a0bd4a 100644 --- a/src/core/pipe.c +++ b/src/core/pipe.c @@ -225,6 +225,20 @@ nni_pipe_get_proto_data(nni_pipe *p) void +nni_pipe_set_tran_data(nni_pipe *p, void *data) +{ + p->p_tran_data = data; +} + + +void * +nni_pipe_get_tran_data(nni_pipe *p) +{ + return (p->p_tran_data); +} + + +void nni_pipe_sock_list_init(nni_list *list) { NNI_LIST_INIT(list, nni_pipe, p_sock_node); diff --git a/src/core/pipe.h b/src/core/pipe.h index 08d7893e..71f3821a 100644 --- a/src/core/pipe.h +++ b/src/core/pipe.h @@ -64,6 +64,15 @@ extern void nni_pipe_set_proto_data(nni_pipe *, void *); // nni_pipe_set_proto_data function. No locking is performed. extern void *nni_pipe_get_proto_data(nni_pipe *); +// nni_pipe_set_tran_data sets the transport private data. No locking is +// performed, and this routine should only be called once per pipe at +// initialization. +extern void nni_pipe_set_tran_data(nni_pipe *, void *); + +// nni_pipe_get_tran_data gets the transport private data set with the +// nni_pipe_set_tran_data function. No locking is performed. +extern void *nni_pipe_get_tran_data(nni_pipe *); + // nni_pipe_sock_list_init initializes a list of pipes, to be used by // a per-socket list. extern void nni_pipe_sock_list_init(nni_list *); diff --git a/src/core/transport.h b/src/core/transport.h index 83ec3121..65cd775f 100644 --- a/src/core/transport.h +++ b/src/core/transport.h @@ -46,11 +46,10 @@ struct nni_tran_ep { // The endpoint will already have been closed. void (*ep_fini)(void *); - // ep_connect establishes a connection, and creates a new pipe, - // which is returned in the final argument. It can return errors + // ep_connect establishes a connection. It can return errors // NNG_EACCESS, NNG_ECONNREFUSED, NNG_EBADADDR, NNG_ECONNFAILED, // NNG_ETIMEDOUT, and NNG_EPROTO. - int (*ep_connect)(void *, void **); + int (*ep_connect)(void *, nni_pipe *); // ep_bind just does the bind() and listen() work, // reserving the address but not creating any connections. @@ -59,9 +58,8 @@ struct nni_tran_ep { // address, or NNG_EACCESS for permission problems. int (*ep_bind)(void *); - // ep_accept accepts an inbound connection, and creates - // a transport pipe, which is returned in the final argument. - int (*ep_accept)(void *, void **); + // ep_accept accepts an inbound connection. + int (*ep_accept)(void *, nni_pipe *); // ep_close stops the endpoint from operating altogether. It does // not affect pipes that have already been created. diff --git a/src/transport/inproc/inproc.c b/src/transport/inproc/inproc.c index 4e329d10..de9b5e91 100644 --- a/src/transport/inproc/inproc.c +++ b/src/transport/inproc/inproc.c @@ -262,7 +262,7 @@ nni_inproc_ep_close(void *arg) static int -nni_inproc_ep_connect(void *arg, void **pipep) +nni_inproc_ep_connect(void *arg, nni_pipe *npipe) { nni_inproc_ep *ep = arg; @@ -303,7 +303,7 @@ nni_inproc_ep_connect(void *arg, void **pipep) nni_list_remove(&server->clients, ep); } } - *pipep = ep->cpipe; + nni_pipe_set_tran_data(npipe, ep->cpipe); ep->cpipe = NULL; nni_mtx_unlock(&nni_inproc.mx); return (0); @@ -342,7 +342,7 @@ nni_inproc_ep_bind(void *arg) static int -nni_inproc_ep_accept(void *arg, void **pipep) +nni_inproc_ep_accept(void *arg, nni_pipe *npipe) { nni_inproc_ep *ep = arg; nni_inproc_ep *client; @@ -393,7 +393,7 @@ nni_inproc_ep_accept(void *arg, void **pipep) pair->pipe[0].peer = ep->proto; pair->refcnt = 2; client->cpipe = &pair->pipe[0]; - *pipep = &pair->pipe[1]; + nni_pipe_set_tran_data(npipe, &pair->pipe[1]); nni_cv_wake(&client->cv); nni_mtx_unlock(&nni_inproc.mx); diff --git a/src/transport/ipc/ipc.c b/src/transport/ipc/ipc.c index 4673a6dc..11965d17 100644 --- a/src/transport/ipc/ipc.c +++ b/src/transport/ipc/ipc.c @@ -260,7 +260,7 @@ nni_ipc_negotiate(nni_ipc_pipe *pipe) static int -nni_ipc_ep_connect(void *arg, void **pipep) +nni_ipc_ep_connect(void *arg, nni_pipe *npipe) { nni_ipc_ep *ep = arg; nni_ipc_pipe *pipe; @@ -295,7 +295,7 @@ nni_ipc_ep_connect(void *arg, void **pipep) NNI_FREE_STRUCT(pipe); return (rv); } - *pipep = pipe; + nni_pipe_set_tran_data(npipe, pipe); return (0); } @@ -321,7 +321,7 @@ nni_ipc_ep_bind(void *arg) static int -nni_ipc_ep_accept(void *arg, void **pipep) +nni_ipc_ep_accept(void *arg, nni_pipe *npipe) { nni_ipc_ep *ep = arg; nni_ipc_pipe *pipe; @@ -349,7 +349,7 @@ nni_ipc_ep_accept(void *arg, void **pipep) NNI_FREE_STRUCT(pipe); return (rv); } - *pipep = pipe; + nni_pipe_set_tran_data(npipe, pipe); return (0); } diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c index ad2d398a..e198a927 100644 --- a/src/transport/tcp/tcp.c +++ b/src/transport/tcp/tcp.c @@ -303,7 +303,7 @@ nni_tcp_negotiate(nni_tcp_pipe *pipe) static int -nni_tcp_ep_connect(void *arg, void **pipep) +nni_tcp_ep_connect(void *arg, nni_pipe *npipe) { nni_tcp_ep *ep = arg; nni_tcp_pipe *pipe; @@ -377,7 +377,7 @@ nni_tcp_ep_connect(void *arg, void **pipep) NNI_FREE_STRUCT(pipe); return (rv); } - *pipep = pipe; + nni_pipe_set_tran_data(npipe, pipe); return (0); } @@ -414,7 +414,7 @@ nni_tcp_ep_bind(void *arg) static int -nni_tcp_ep_accept(void *arg, void **pipep) +nni_tcp_ep_accept(void *arg, nni_pipe *npipe) { nni_tcp_ep *ep = arg; nni_tcp_pipe *pipe; @@ -442,7 +442,7 @@ nni_tcp_ep_accept(void *arg, void **pipep) NNI_FREE_STRUCT(pipe); return (rv); } - *pipep = pipe; + nni_pipe_set_tran_data(npipe, pipe); return (0); } |
