diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-07-02 12:58:53 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-07-02 12:58:53 -0700 |
| commit | 424c2238c97d26d8d5fb30fb1449a96396269da0 (patch) | |
| tree | a5d3ed01e348f4644b06d630a3e92997944152f6 /src/core | |
| parent | 53a22a96d49e8b44c7e70b59559db87f57158a82 (diff) | |
| download | nng-424c2238c97d26d8d5fb30fb1449a96396269da0.tar.gz nng-424c2238c97d26d8d5fb30fb1449a96396269da0.tar.bz2 nng-424c2238c97d26d8d5fb30fb1449a96396269da0.zip | |
Transports allocate their pipe structures during connect & accept.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/endpt.c | 4 | ||||
| -rw-r--r-- | src/core/pipe.c | 2 | ||||
| -rw-r--r-- | src/core/transport.h | 15 |
3 files changed, 10 insertions, 11 deletions
diff --git a/src/core/endpt.c b/src/core/endpt.c index e3f78ecd..223d86a3 100644 --- a/src/core/endpt.c +++ b/src/core/endpt.c @@ -245,7 +245,7 @@ nni_ep_connect(nni_ep *ep) 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->p_tran_data); if (rv != 0) { nni_pipe_remove(pipe); return (rv); @@ -411,7 +411,7 @@ nni_ep_accept(nni_ep *ep) 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->p_tran_data); if (rv != 0) { nni_pipe_remove(pipe); return (rv); diff --git a/src/core/pipe.c b/src/core/pipe.c index 791ba4aa..ebf7adef 100644 --- a/src/core/pipe.c +++ b/src/core/pipe.c @@ -192,11 +192,13 @@ nni_pipe_create(nni_pipe **pp, nni_ep *ep, nni_sock *sock, nni_tran *tran) // Save the protocol destructor. p->p_proto_dtor = sock->s_pipe_ops.pipe_fini; +#if 0 // Initialize the transport pipe data. if ((rv = p->p_tran_ops.p_init(&p->p_tran_data)) != 0) { nni_objhash_unref(nni_pipes, p->p_id); return (rv); } +#endif // Initialize protocol pipe data. rv = sock->s_pipe_ops.pipe_init(&p->p_proto_data, p, sock->s_data); diff --git a/src/core/transport.h b/src/core/transport.h index d965201a..0ec7310a 100644 --- a/src/core/transport.h +++ b/src/core/transport.h @@ -49,9 +49,9 @@ struct nni_tran_ep { // ep_connect establishes a connection. It can return errors // NNG_EACCESS, NNG_ECONNREFUSED, NNG_EBADADDR, NNG_ECONNFAILED, // NNG_ETIMEDOUT, and NNG_EPROTO. The first argument is the - // transport specific endpoint, and the second is the transport - // specific pipe structure. - int (*ep_connect)(void *, void *); + // transport specific endpoint, and the second is a pointer to + // receive a newly created transport-specific pipe structure. + int (*ep_connect)(void *, void **); // ep_bind just does the bind() and listen() work, // reserving the address but not creating any connections. @@ -61,9 +61,9 @@ struct nni_tran_ep { int (*ep_bind)(void *); // ep_accept accepts an inbound connection. The first argument - // is the transport-specific endpoint, and the second is the - // transport-specific pipe (which will have already been created.) - int (*ep_accept)(void *, void *); + // is the transport-specific endpoint, and the second is a pointer to + // a transport-specific pipe, created by this function. + int (*ep_accept)(void *, void **); // ep_close stops the endpoint from operating altogether. It does // not affect pipes that have already been created. @@ -81,9 +81,6 @@ struct nni_tran_ep { // back into the socket at this point. (Which is one reason pointers back // to socket or even enclosing pipe state, are not provided.) struct nni_tran_pipe { - // p_init initializes the pipe structure, allocating the structure. - int (*p_init)(void **); - // p_fini destroys the pipe. This should clean up all local // resources, including closing files and freeing memory, used by // the pipe. After this call returns, the system will not make |
