From 890e6f9465fa00067f6c357e238c439128bd848f Mon Sep 17 00:00:00 2001 From: radkesvat <134321679+radkesvat@users.noreply.github.com> Date: Wed, 24 Apr 2024 21:04:11 +0000 Subject: [PATCH] put the buffer back to the pool when userdata is null --- tunnels/adapters/connector/tcp/tcp_connector.c | 1 + tunnels/adapters/connector/udp/udp_connector.c | 6 +++++- tunnels/adapters/listener/tcp/tcp_listener.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tunnels/adapters/connector/tcp/tcp_connector.c b/tunnels/adapters/connector/tcp/tcp_connector.c index 5ccc56dd..05c35baa 100644 --- a/tunnels/adapters/connector/tcp/tcp_connector.c +++ b/tunnels/adapters/connector/tcp/tcp_connector.c @@ -128,6 +128,7 @@ static void onRecv(hio_t *restrict io, shift_buffer_t *buf) tcp_connector_con_state_t *cstate = (tcp_connector_con_state_t *) (hevent_userdata(io)); if (cstate == NULL) { + reuseBuffer(hloop_bufferpool(hevent_loop(io)),buf); return; } shift_buffer_t *payload = buf; diff --git a/tunnels/adapters/connector/udp/udp_connector.c b/tunnels/adapters/connector/udp/udp_connector.c index 96771644..1460a24d 100644 --- a/tunnels/adapters/connector/udp/udp_connector.c +++ b/tunnels/adapters/connector/udp/udp_connector.c @@ -11,7 +11,11 @@ static void cleanup(udp_connector_con_state_t *cstate) static void onRecv(hio_t *io, shift_buffer_t *buf) { udp_connector_con_state_t *cstate = (udp_connector_con_state_t *) (hevent_userdata(io)); - + if (cstate == NULL) + { + reuseBuffer(hloop_bufferpool(hevent_loop(io)),buf); + return; + } shift_buffer_t *payload = buf; tunnel_t * self = (cstate)->tunnel; line_t * line = (cstate)->line; diff --git a/tunnels/adapters/listener/tcp/tcp_listener.c b/tunnels/adapters/listener/tcp/tcp_listener.c index feabb26c..714083e8 100644 --- a/tunnels/adapters/listener/tcp/tcp_listener.c +++ b/tunnels/adapters/listener/tcp/tcp_listener.c @@ -253,6 +253,7 @@ static void onRecv(hio_t *io, shift_buffer_t *buf) tcp_listener_con_state_t *cstate = (tcp_listener_con_state_t *) (hevent_userdata(io)); if (cstate == NULL) { + reuseBuffer(hloop_bufferpool(hevent_loop(io)),buf); return; } shift_buffer_t *payload = buf;