Skip to content

Commit

Permalink
put the buffer back to the pool when userdata is null
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Apr 24, 2024
1 parent faa413a commit 890e6f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions tunnels/adapters/connector/tcp/tcp_connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion tunnels/adapters/connector/udp/udp_connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions tunnels/adapters/listener/tcp/tcp_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 890e6f9

Please sign in to comment.