diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-07-16 13:25:58 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-07-16 13:25:58 -0700 |
| commit | 396d8a243df89680b850626193e0b23567b02585 (patch) | |
| tree | 9960dd986ce569031142a90dacc1c3986a3e3578 /src/core/pipe.c | |
| parent | fd037da0609df87b755e379eef93ed11ab14f55f (diff) | |
| download | nng-396d8a243df89680b850626193e0b23567b02585.tar.gz nng-396d8a243df89680b850626193e0b23567b02585.tar.bz2 nng-396d8a243df89680b850626193e0b23567b02585.zip | |
Bind the pipe to the ep properly, and wake any closers needed.
Diffstat (limited to 'src/core/pipe.c')
| -rw-r--r-- | src/core/pipe.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/core/pipe.c b/src/core/pipe.c index e458a89d..c98a3243 100644 --- a/src/core/pipe.c +++ b/src/core/pipe.c @@ -120,10 +120,16 @@ nni_pipe_reap(nni_pipe *p) // Transport close... nni_pipe_close(p); - // Tell the protocol to stop. - nni_sock_pipe_stop(p->p_sock, p); + // Remove the pipe from the socket and the endpoint. Note + // that it is in theory possible for either of these to be null + // if the pipe is being torn down before it is fully initialized. + if (p->p_ep != NULL) { + nni_ep_pipe_remove(p->p_ep, p); + } + if (p->p_sock != NULL) { + nni_sock_pipe_remove(p->p_sock, p); + } - // XXX: would be simpler to just do a destroy here nni_pipe_destroy(p); } @@ -208,8 +214,13 @@ nni_pipe_create(nni_ep *ep, void *tdata) p->p_tran_ops = *tran->tran_pipe; p->p_tran_data = tdata; - // Attempt to initialize protocol data. - if ((rv = nni_sock_pipe_init(sock, p)) != 0) { + // Attempt to initialize sock protocol & endpoint. + if ((rv = nni_ep_pipe_add(ep, p)) != 0) { + nni_pipe_destroy(p); + return (rv); + } + if ((rv = nni_sock_pipe_add(sock, p)) != 0) { + nni_ep_pipe_remove(ep, p); nni_pipe_destroy(p); return (rv); } |
