From 8fe11dfb66acfe067b21b6eb47eb9e3928169950 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 31 Dec 2016 11:53:27 -0800 Subject: Fix races in pipe termination. --- src/core/pipe.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/core/pipe.c') diff --git a/src/core/pipe.c b/src/core/pipe.c index 0a3f1d33..b57b7831 100644 --- a/src/core/pipe.c +++ b/src/core/pipe.c @@ -98,7 +98,11 @@ nni_pipe_create(nni_pipe **pp, nni_endpt *ep) if ((p = nni_alloc(sizeof (*p))) == NULL) { return (NNG_ENOMEM); } + p->p_send_thr = NULL; + p->p_recv_thr = NULL; p->p_trandata = NULL; + p->p_active = 0; + p->p_abort = 0; if ((rv = nni_cond_init(&p->p_cv, &sock->s_mx)) != 0) { nni_free(p, sizeof (*p)); return (rv); @@ -112,8 +116,6 @@ nni_pipe_create(nni_pipe **pp, nni_endpt *ep) p->p_sock = sock; p->p_ops = *ep->ep_ops.ep_pipe_ops; p->p_ep = ep; - p->p_active = 0; - p->p_abort = 0; if (ep->ep_dialer != NULL) { ep->ep_pipe = p; } @@ -207,7 +209,7 @@ nni_pipe_start(nni_pipe *pipe) if (rv != 0) { goto fail; } - rv = nni_thread_create(&pipe->p_send_thr, nni_pipe_receiver, pipe); + rv = nni_thread_create(&pipe->p_recv_thr, nni_pipe_receiver, pipe); if (rv != 0) { goto fail; } -- cgit v1.2.3-70-g09d2