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/socket.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/socket.c')
| -rw-r--r-- | src/core/socket.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/core/socket.c b/src/core/socket.c index ecddf5dd..52732cde 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -78,12 +78,16 @@ nni_sock_rele(nni_sock *sock) } int -nni_sock_pipe_init(nni_sock *sock, nni_pipe *pipe) +nni_sock_pipe_add(nni_sock *sock, nni_pipe *pipe) { int rv; // Initialize protocol pipe data. nni_mtx_lock(&sock->s_mx); + if (sock->s_closing) { + nni_mtx_unlock(&sock->s_mx); + return (NNG_ECLOSED); + } rv = sock->s_pipe_ops.pipe_init( &pipe->p_proto_data, pipe, sock->s_data); if (rv != 0) { @@ -126,7 +130,7 @@ nni_sock_pipe_ready(nni_sock *sock, nni_pipe *pipe) } void -nni_sock_pipe_stop(nni_sock *sock, nni_pipe *pipe) +nni_sock_pipe_remove(nni_sock *sock, nni_pipe *pipe) { void * pdata; nni_ep *ep; @@ -140,19 +144,6 @@ nni_sock_pipe_stop(nni_sock *sock, nni_pipe *pipe) return; } - // Break up the relationship between the EP and the pipe. - if ((ep = pipe->p_ep) != NULL) { - nni_mtx_lock(&ep->ep_mtx); - // During early init, the pipe might not have this set. - if (nni_list_active(&ep->ep_pipes, pipe)) { - nni_list_remove(&ep->ep_pipes, pipe); - } - pipe->p_ep = NULL; - ep->ep_pipe = NULL; // XXX: remove this soon - nni_cv_wake(&ep->ep_cv); - nni_mtx_unlock(&ep->ep_mtx); - } - sock->s_pipe_ops.pipe_stop(pdata); if (nni_list_active(&sock->s_pipes, pipe)) { nni_list_remove(&sock->s_pipes, pipe); |
