From 396d8a243df89680b850626193e0b23567b02585 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 16 Jul 2017 13:25:58 -0700 Subject: Bind the pipe to the ep properly, and wake any closers needed. --- src/core/socket.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'src/core/socket.c') 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); -- cgit v1.2.3-70-g09d2