Skip to content

Commit

Permalink
refactor: move econnaborted to closed_nostart counter group
Browse files Browse the repository at this point in the history
  • Loading branch information
zmstone committed Nov 11, 2024
1 parent 7459481 commit 1a86898
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/esockd_acceptor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,11 @@ handle_event(internal, accept_and_close, suspending, State = #state{lsock = LSoc
{keep_state, State#state{accept_ref = Ref}};
{error, Reason} when
Reason =:= emfile;
Reason =:= enfile
Reason =:= enfile;
Reason =:= econnaborted
->
inc_stats(State, Reason),
{keep_state_and_data, {next_event, internal, accept_and_close}};
{error, econnaborted} ->
inc_stats(State, econnaborted),
{keep_state_and_data, {next_event, internal, accept_and_close}};
{error, closed} ->
{stop, normal, State};
{error, Reason} ->
Expand Down Expand Up @@ -283,14 +281,12 @@ handle_socket_error(closed, State, _StateName) ->
{stop, normal, State};
%% {error, econnaborted} -> accept
%% {error, esslaccept} -> accept
%% {error, esslaccept} -> accept
handle_socket_error(Reason, State, suspending) when Reason =:= econnaborted; Reason =:= esslaccept ->
{keep_state, State, {next_event, internal, accept_and_close}};
handle_socket_error(Reason, State, _StateName) when Reason =:= econnaborted; Reason =:= esslaccept ->
{next_state, waiting, State, {next_event, internal, begin_waiting}};
%% emfile: The per-process limit of open file descriptors has been reached.
%% enfile: The system limit on the total number of open files has been reached.
%% enfile: The system limit on the total number of open files has been reached.
handle_socket_error(Reason, State, suspending) when Reason =:= emfile; Reason =:= enfile ->
log_system_limit(State, Reason),
_ = {keep_state, State, {next_event, internal, accept_and_close}};
Expand Down Expand Up @@ -322,6 +318,9 @@ inc_stats(#state{proto = Proto, listen_on = ListenOn}, Tag) ->
ok.

counter(accepted) -> accepted;
counter(econnaborted) -> closed_nostart;
%% unsure how this could happen
counter(esslaccept ) -> closed_nostart;
counter(closed_nostart) -> closed_nostart;
counter(emfile) -> closed_overloaded;
counter(enfile) -> closed_overloaded;
Expand Down

0 comments on commit 1a86898

Please sign in to comment.