Skip to content

Commit

Permalink
Merge pull request #28 from emqtt/issue#27
Browse files Browse the repository at this point in the history
Fix issue#27 - {accept_error,econnaborted} crasher
  • Loading branch information
Feng Lee committed Apr 28, 2016
2 parents e6c2780 + 0a931c3 commit 97fddcd
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/esockd_acceptor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,21 @@ handle_info({inet_async, LSock, Ref, {error, closed}},
%% know this will fail.
{stop, normal, State};

%% {error, econnaborted} -> accept
handle_info({inet_async, LSock, Ref, {error, econnaborted}},
State=#state{lsock = LSock, ref = Ref}) ->
accept(State);

%% {error, esslaccept} -> accept
handle_info({inet_async, LSock, Ref, {error, esslaccept}},
State=#state{lsock = LSock, ref = Ref}) ->
accept(State);

%% async accept errors...
%% {error, timeout} ->
%% {error, econnaborted} -> ??continue?
%% {error, esslaccept} ->
%% {error, e{n,m}file} -> suspend 100??
handle_info({inet_async, LSock, Ref, {error, Error}},
State=#state{lsock=LSock, ref=Ref}) ->
State=#state{lsock = LSock, ref = Ref}) ->
sockerr(Error, State);

handle_info(resume, State) ->
Expand All @@ -151,6 +159,7 @@ code_change(_OldVsn, State, _Extra) ->
%%--------------------------------------------------------------------
%% accept...
%%--------------------------------------------------------------------

accept(State = #state{lsock = LSock}) ->
case prim_inet:async_accept(LSock, -1) of
{ok, Ref} ->
Expand Down

0 comments on commit 97fddcd

Please sign in to comment.