diff options
| author | Garrett D'Amore <garrett@damore.org> | 2021-07-07 14:12:38 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2021-07-07 14:12:38 -0700 |
| commit | 886ef5bc75e1e1f7b549692ede55cdfc8e85ef8c (patch) | |
| tree | 524eb0753f94115e8d7b43be90103b05aa816bbe | |
| parent | 34ff91cdbaec8559aad84aacac96541c18288ebc (diff) | |
| download | nng-886ef5bc75e1e1f7b549692ede55cdfc8e85ef8c.tar.gz nng-886ef5bc75e1e1f7b549692ede55cdfc8e85ef8c.tar.bz2 nng-886ef5bc75e1e1f7b549692ede55cdfc8e85ef8c.zip | |
Fix leaking pipes after close.
| -rw-r--r-- | src/core/socket.c | 19 |
1 files changed, 14 insertions, 5 deletions
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. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // 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; } |
