Merge pull request #13467 from ieQu1/dev/optimize-connection-process_msg

fix(connection): Make process_msg function tail-recursive
This commit is contained in:
ieQu1 2024-07-15 17:00:50 +02:00 committed by GitHub
commit 706cab3c86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 13 deletions

View File

@ -468,19 +468,17 @@ cancel_stats_timer(State) ->
process_msg([], State) ->
{ok, State};
process_msg([Msg | More], State) ->
try
case handle_msg(Msg, State) of
ok ->
process_msg(More, State);
{ok, NState} ->
process_msg(More, NState);
{ok, Msgs, NState} ->
process_msg(append_msg(More, Msgs), NState);
{stop, Reason, NState} ->
{stop, Reason, NState};
{stop, Reason} ->
{stop, Reason, State}
end
try handle_msg(Msg, State) of
ok ->
process_msg(More, State);
{ok, NState} ->
process_msg(More, NState);
{ok, Msgs, NState} ->
process_msg(append_msg(More, Msgs), NState);
{stop, Reason, NState} ->
{stop, Reason, NState};
{stop, Reason} ->
{stop, Reason, State}
catch
exit:normal ->
{stop, normal, State};