aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-10-03 12:57:04 -0700
committerGarrett D'Amore <garrett@damore.org>2017-10-03 12:57:04 -0700
commit557964482f2b9d4246a2943fb1bedc6074d01e0d (patch)
tree323d8ca977e9d25aa827dc9e272e84630adb8c3e /src/core
parent6fef4c1e5bf73ad76e7cdcfb65540f1308045339 (diff)
downloadnng-557964482f2b9d4246a2943fb1bedc6074d01e0d.tar.gz
nng-557964482f2b9d4246a2943fb1bedc6074d01e0d.tar.bz2
nng-557964482f2b9d4246a2943fb1bedc6074d01e0d.zip
fixes #99 Still seeing segfaults in pair1 (rarely)
Diffstat (limited to 'src/core')
-rw-r--r--src/core/socket.c14
1 files changed, 6 insertions, 8 deletions
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