Skip to content

Commit

Permalink
fix issue#9
Browse files Browse the repository at this point in the history
  • Loading branch information
Ery Lee committed Apr 9, 2015
1 parent a043231 commit 4377127
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
5 changes: 3 additions & 2 deletions src/esockd_acceptor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ handle_info({inet_async, LSock, Ref, {ok, Sock}}, State = #state{lsock = LSoc
%% accepted stats.
AcceptStatsFun({inc, 1}),

{ok, Peername} = inet:peername(Sock),
Logger:info("~s - Accept from ~s", [SockName, esockd_net:format(peername, Peername)]),
%% fix issues#9: enotconn error occured...
%{ok, Peername} = inet:peername(Sock),
%Logger:info("~s - Accept from ~s", [SockName, esockd_net:format(peername, Peername)]),
case BufferTuneFun(Sock) of
ok ->
case esockd_connection_sup:start_connection(ConnSup, Mod, Sock, SockFun) of
Expand Down
34 changes: 19 additions & 15 deletions src/esockd_connection_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,26 @@ handle_call({start_connection, _SockArgs}, _From, State = #state{curr_clients =

handle_call({start_connection, SockArgs = {_, Sock, _SockFun}}, _From,
State = #state{mfargs = MFArgs, curr_clients = Count, access_rules = Rules}) ->
{ok, {Addr, _Port}} = inet:peername(Sock),
case allowed(Addr, Rules) of
true ->
case catch esockd_connection:start_link(SockArgs, MFArgs) of
{ok, Pid} when is_pid(Pid) ->
put(Pid, true),
{reply, {ok, Pid}, State#state{curr_clients = Count+1}};
ignore ->
{reply, ignore, State};
{error, Reason} ->
{reply, {error, Reason}, State};
What ->
{reply, {error, What}, State}
case inet:peername(Sock) of
{ok, {Addr, _Port}} ->
case allowed(Addr, Rules) of
true ->
case catch esockd_connection:start_link(SockArgs, MFArgs) of
{ok, Pid} when is_pid(Pid) ->
put(Pid, true),
{reply, {ok, Pid}, State#state{curr_clients = Count+1}};
ignore ->
{reply, ignore, State};
{error, Reason} ->
{reply, {error, Reason}, State};
What ->
{reply, {error, What}, State}
end;
false ->
{reply, {error, fobidden}, State}
end;
false ->
{reply, {error, fobidden}, State}
{error, Reason} ->
{reply, {error, Reason}, State}
end;

handle_call(count_connections, _From, State = #state{curr_clients = Count}) ->
Expand Down

0 comments on commit 4377127

Please sign in to comment.