diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-03-19 22:08:17 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-03-19 22:08:17 -0700 |
| commit | 6091cf7e1c030417e1fd29c66160e71bcbe4f984 (patch) | |
| tree | c95a46550370a06cb10263e77e7419260c83fba5 /src/core | |
| parent | 9fe905a8040a7e089233125a003ef8911d98ddbd (diff) | |
| download | nng-6091cf7e1c030417e1fd29c66160e71bcbe4f984.tar.gz nng-6091cf7e1c030417e1fd29c66160e71bcbe4f984.tar.bz2 nng-6091cf7e1c030417e1fd29c66160e71bcbe4f984.zip | |
More interface hiding. (pipe tran data setting).
Diffstat (limited to 'src/core')
| -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 |
5 files changed, 30 insertions, 9 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. |
