From 886ef5bc75e1e1f7b549692ede55cdfc8e85ef8c Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 7 Jul 2021 14:12:38 -0700 Subject: Fix leaking pipes after close. --- src/core/socket.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/socket.c b/src/core/socket.c index 90a99c20..16476be1 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. +// Copyright 2021 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -1498,8 +1498,12 @@ nni_dialer_add_pipe(nni_dialer *d, void *tpipe) nni_mtx_lock(&s->s_mx); - if (s->s_closed || d->d_closing || - (nni_pipe_create_dialer(&p, d, tpipe) != 0)) { + if (s->s_closed || d->d_closing) { + d->d_tran->tran_pipe->p_fini(tpipe); + nni_mtx_unlock(&s->s_mx); + return; + } + if (nni_pipe_create_dialer(&p, d, tpipe) != 0) { nni_mtx_unlock(&s->s_mx); return; } @@ -1635,8 +1639,13 @@ nni_listener_add_pipe(nni_listener *l, void *tpipe) nni_pipe *p; nni_mtx_lock(&s->s_mx); - if (s->s_closed || l->l_closing || - (nni_pipe_create_listener(&p, l, tpipe) != 0)) { + if (s->s_closed || l->l_closing) { + l->l_tran->tran_pipe->p_fini(tpipe); + nni_mtx_unlock(&s->s_mx); + return; + } + + if (nni_pipe_create_listener(&p, l, tpipe) != 0) { nni_mtx_unlock(&s->s_mx); return; } -- cgit v1.2.3-70-g09d2