Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #1713 SP pipe_send leaks message if aio is canceled #1715

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/sp/transport/inproc/inproc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2018 Devolutions <info@devolutions.net>
//
Expand Down Expand Up @@ -207,6 +207,10 @@
int rv;

if (nni_aio_begin(aio) != 0) {
// No way to give the message back to the protocol, so
// we just discard it silently to prevent it from leaking.
nni_msg_free(nni_aio_get_msg(aio));
nni_aio_set_msg(aio, NULL);

Check warning on line 213 in src/sp/transport/inproc/inproc.c

View check run for this annotation

Codecov / codecov/patch

src/sp/transport/inproc/inproc.c#L212-L213

Added lines #L212 - L213 were not covered by tests
return;
}

Expand Down
4 changes: 4 additions & 0 deletions src/sp/transport/ipc/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@
int rv;

if (nni_aio_begin(aio) != 0) {
// No way to give the message back to the protocol, so
// we just discard it silently to prevent it from leaking.
nni_msg_free(nni_aio_get_msg(aio));
nni_aio_set_msg(aio, NULL);

Check warning on line 524 in src/sp/transport/ipc/ipc.c

View check run for this annotation

Codecov / codecov/patch

src/sp/transport/ipc/ipc.c#L523-L524

Added lines #L523 - L524 were not covered by tests
return;
}
nni_mtx_lock(&p->mtx);
Expand Down
6 changes: 5 additions & 1 deletion src/sp/transport/tcp/tcp.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2019 Devolutions <info@devolutions.net>
//
Expand Down Expand Up @@ -512,6 +512,10 @@
int rv;

if (nni_aio_begin(aio) != 0) {
// No way to give the message back to the protocol, so
// we just discard it silently to prevent it from leaking.
nni_msg_free(nni_aio_get_msg(aio));
nni_aio_set_msg(aio, NULL);

Check warning on line 518 in src/sp/transport/tcp/tcp.c

View check run for this annotation

Codecov / codecov/patch

src/sp/transport/tcp/tcp.c#L517-L518

Added lines #L517 - L518 were not covered by tests
return;
}
nni_mtx_lock(&p->mtx);
Expand Down
6 changes: 5 additions & 1 deletion src/sp/transport/tls/tls.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2019 Devolutions <info@devolutions.net>
//
Expand Down Expand Up @@ -498,6 +498,10 @@
int rv;

if (nni_aio_begin(aio) != 0) {
// No way to give the message back to the protocol, so
// we just discard it silently to prevent it from leaking.
nni_msg_free(nni_aio_get_msg(aio));
nni_aio_set_msg(aio, NULL);

Check warning on line 504 in src/sp/transport/tls/tls.c

View check run for this annotation

Codecov / codecov/patch

src/sp/transport/tls/tls.c#L503-L504

Added lines #L503 - L504 were not covered by tests
return;
}
nni_mtx_lock(&p->mtx);
Expand Down
6 changes: 5 additions & 1 deletion src/sp/transport/ws/websocket.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2019 Devolutions <info@devolutions.net>
//
Expand Down Expand Up @@ -158,6 +158,10 @@
int rv;

if (nni_aio_begin(aio) != 0) {
// No way to give the message back to the protocol, so
// we just discard it silently to prevent it from leaking.
nni_msg_free(nni_aio_get_msg(aio));
nni_aio_set_msg(aio, NULL);

Check warning on line 164 in src/sp/transport/ws/websocket.c

View check run for this annotation

Codecov / codecov/patch

src/sp/transport/ws/websocket.c#L163-L164

Added lines #L163 - L164 were not covered by tests
return;
}
nni_mtx_lock(&p->mtx);
Expand Down
6 changes: 5 additions & 1 deletion src/sp/transport/zerotier/zerotier.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2021 Capitar IT Group BV <info@capitar.com>
// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
Expand Down Expand Up @@ -1821,6 +1821,10 @@ zt_pipe_send(void *arg, nni_aio *aio)
nni_msg *m;

if (nni_aio_begin(aio) != 0) {
// No way to give the message back to the protocol, so
// we just discard it silently to prevent it from leaking.
nni_msg_free(nni_aio_get_msg(aio));
nni_aio_set_msg(aio, NULL);
return;
}
if ((m = nni_aio_get_msg(aio)) == NULL) {
Expand Down
Loading