From 2ea7ae1ae5755ab72833fdea0dcf8e13e4d91d0d Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 3 Jan 2018 13:04:44 -0800 Subject: Fix leaks on send. I'm pretty sure I need to go back and review the handling of send messages for websocket too. We still have a receive leak in websocket and leaks caused by the new URL parsing code which needs to be refactored. --- src/core/aio.c | 1 + src/transport/ipc/ipc.c | 5 +++-- src/transport/tcp/tcp.c | 5 +++-- src/transport/tls/tls.c | 5 +++-- src/transport/ws/websocket.c | 6 ++++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/core/aio.c b/src/core/aio.c index 6ce5641d..350bf52a 100644 --- a/src/core/aio.c +++ b/src/core/aio.c @@ -308,6 +308,7 @@ nni_aio_finish_impl( NNI_ASSERT(aio->a_pend == 0); // provider only calls us *once* nni_list_node_remove(&aio->a_expire_node); + aio->a_pend = 1; aio->a_result = result; aio->a_count = count; diff --git a/src/transport/ipc/ipc.c b/src/transport/ipc/ipc.c index 32ff1c0e..84292bb8 100644 --- a/src/transport/ipc/ipc.c +++ b/src/transport/ipc/ipc.c @@ -1,6 +1,6 @@ // -// Copyright 2017 Garrett D'Amore -// Copyright 2017 Capitar IT Group BV +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -252,6 +252,7 @@ nni_ipc_pipe_send_cb(void *arg) msg = nni_aio_get_msg(aio); n = nni_msg_len(msg); nni_aio_set_msg(aio, NULL); + nni_msg_free(msg); nni_aio_finish(aio, 0, n); } diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c index d6a51faa..538833c2 100644 --- a/src/transport/tcp/tcp.c +++ b/src/transport/tcp/tcp.c @@ -1,6 +1,6 @@ // -// Copyright 2017 Garrett D'Amore -// Copyright 2017 Capitar IT Group BV +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -251,6 +251,7 @@ nni_tcp_pipe_send_cb(void *arg) msg = nni_aio_get_msg(aio); n = nni_msg_len(msg); nni_aio_set_msg(aio, NULL); + nni_msg_free(msg); nni_aio_finish(aio, 0, n); } diff --git a/src/transport/tls/tls.c b/src/transport/tls/tls.c index 1104d4b2..21798c04 100644 --- a/src/transport/tls/tls.c +++ b/src/transport/tls/tls.c @@ -1,6 +1,6 @@ // -// Copyright 2017 Staysail Systems, Inc. -// Copyright 2017 Capitar IT Group BV +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -261,6 +261,7 @@ nni_tls_pipe_send_cb(void *arg) msg = nni_aio_get_msg(aio); n = nni_msg_len(msg); nni_aio_set_msg(aio, NULL); + nni_msg_free(msg); nni_aio_finish(aio, 0, n); } diff --git a/src/transport/ws/websocket.c b/src/transport/ws/websocket.c index 977119a2..05cb9513 100644 --- a/src/transport/ws/websocket.c +++ b/src/transport/ws/websocket.c @@ -119,6 +119,8 @@ ws_pipe_recv_cancel(nni_aio *aio, int rv) return; } nni_aio_cancel(p->rxaio, rv); + p->user_rxaio = NULL; + nni_aio_finish_error(aio, rv); nni_mtx_unlock(&p->mtx); } @@ -147,9 +149,9 @@ ws_pipe_send_cancel(nni_aio *aio, int rv) nni_mtx_unlock(&p->mtx); return; } - // This aborts the upper send, which will call back with an error - // when it is done. + p->user_txaio = NULL; nni_aio_cancel(p->txaio, rv); + nni_aio_finish_error(aio, rv); nni_mtx_unlock(&p->mtx); } -- cgit v1.2.3-70-g09d2