Skip to content

Commit

Permalink
removed redundant recv_loop/4
Browse files Browse the repository at this point in the history
  • Loading branch information
iamaleksey committed Feb 4, 2010
1 parent b005a50 commit 40872ad
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions src/smpp_session.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
-export([congestion/3, connect/1, listen/1]).

%%% SOCKET LISTENER FUNCTIONS EXPORTS
-export([wait_accept/3, wait_recv/3, wait_recv/4, recv_loop/4]).
-export([wait_accept/3, wait_recv/3, wait_recv/4]).

%% TIMER EXPORTS
-export([cancel_timer/1, start_timer/2]).
Expand Down Expand Up @@ -149,29 +149,12 @@ wait_recv(Pid, Sock, Buffer, Log) ->
{ok, Input} ->
L = timer:now_diff(now(), Timestamp),
B = handle_input(Pid, concat_binary([Buffer, Input]), L, 1, Log),
case recv_loop(Pid, Sock, B, Log) of
{ok, NewBuffer} ->
?MODULE:wait_recv(Pid, Sock, NewBuffer, Log);
RecvError ->
gen_fsm:send_all_state_event(Pid, RecvError)
end;
?MODULE:wait_recv(Pid, Sock, B, Log);
{error, Reason} ->
gen_fsm:send_all_state_event(Pid, {sock_error, Reason})
end.


recv_loop(Pid, Sock, Buffer, Log) ->
case gen_tcp:recv(Sock, 0, 0) of
{ok, Input} -> % Some input waiting already
B = handle_input(Pid, concat_binary([Buffer, Input]), 0, 1, Log),
?MODULE:recv_loop(Pid, Sock, B, Log);
{error, timeout} -> % No data inmediately available
{ok, Buffer};
{error, Reason} ->
{sock_error, Reason}
end.


handle_input(Pid, <<CmdLen:32, Rest/binary>> = Buffer, Lapse, N, Log) ->
Now = now(), % PDU received. PDU handling starts now!
Len = CmdLen - 4,
Expand Down

0 comments on commit 40872ad

Please sign in to comment.