Skip to content

Commit 26fe4bc

Browse files
committed
bugfix: Clear .hello_acc in mtp_handler when no longer needed
Before fix accumulator was never cleaned, taking memory. Clear the accumulator on transition to tunnel stage (handshake complete) and on transition to fronting stage (data already forwarded to front_sock).
1 parent f24b70d commit 26fe4bc

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/mtp_handler.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ parse_upstream_data(<<Header:64/binary, Rest/binary>>,
427427
dc_id = {RealDcId, Pool},
428428
codec = Codec,
429429
policy_state = PState,
430-
stage = tunnel},
430+
stage = tunnel,
431+
hello_acc = <<>>},
431432
hibernate));
432433
{error, Reason} when is_atom(Reason) ->
433434
mtp_metric:count_inc([?APP, protocol_error, total], 1, #{labels => [Listener, Reason]}),
@@ -538,7 +539,7 @@ do_front(SniDomain, Config, Data, Ip, Listener,
538539
ok = gen_tcp:send(FrontSock, Data),
539540
ok = Transport:setopts(Sock, [{active, once}]),
540541
?LOG_INFO("Domain fronting to ~s:~p for SNI ~s", [Host, Port, SniDomain]),
541-
{ok, S#state{stage = fronting, front_sock = FrontSock}};
542+
{ok, S#state{stage = fronting, front_sock = FrontSock, hello_acc = <<>>}};
542543
{error, Reason} ->
543544
?LOG_WARNING("Domain fronting connect to ~s:~p failed: ~p",
544545
[Host, Port, Reason]),

0 commit comments

Comments
 (0)