From 557964482f2b9d4246a2943fb1bedc6074d01e0d Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 3 Oct 2017 12:57:04 -0700 Subject: fixes #99 Still seeing segfaults in pair1 (rarely) --- src/core/socket.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/core/socket.c') diff --git a/src/core/socket.c b/src/core/socket.c index e1cb1294..d613ac0e 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -341,22 +341,20 @@ nni_sock_pipe_remove(nni_sock *sock, nni_pipe *pipe) { void *pdata; + nni_mtx_lock(&sock->s_mx); pdata = nni_pipe_get_proto_data(pipe); - if (pdata != NULL) { - nni_mtx_lock(&sock->s_mx); sock->s_pipe_ops.pipe_stop(pdata); + nni_pipe_set_proto_data(pipe, NULL); if (nni_list_active(&sock->s_pipes, pipe)) { nni_list_remove(&sock->s_pipes, pipe); - if (sock->s_closing && - nni_list_empty(&sock->s_pipes)) { - nni_cv_wake(&sock->s_cv); - } } sock->s_pipe_ops.pipe_fini(pdata); - nni_pipe_set_proto_data(pipe, NULL); - nni_mtx_unlock(&sock->s_mx); } + if (sock->s_closing && nni_list_empty(&sock->s_pipes)) { + nni_cv_wake(&sock->s_cv); + } + nni_mtx_unlock(&sock->s_mx); } void -- cgit v1.2.3-70-g09d2