25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Don't ignore send() result

This commit is contained in:
Evgeniy Khramtsov 2018-07-03 13:44:58 +03:00
parent b341a3cef3
commit 295bec8551

View File

@ -245,14 +245,19 @@ handle_sync_event(_Event, _From, StateName,
%%%-------------------------------------------------
relay(MySocket, PeerSocket, Shaper) ->
case gen_tcp:recv(MySocket, 0) of
{ok, Data} ->
gen_tcp:send(PeerSocket, Data),
{NewShaper, Pause} = shaper:update(Shaper, byte_size(Data)),
if Pause > 0 -> timer:sleep(Pause);
true -> pass
end,
relay(MySocket, PeerSocket, NewShaper);
_ -> stopped
{ok, Data} ->
case gen_tcp:send(PeerSocket, Data) of
ok ->
{NewShaper, Pause} = shaper:update(Shaper, byte_size(Data)),
if Pause > 0 -> timer:sleep(Pause);
true -> pass
end,
relay(MySocket, PeerSocket, NewShaper);
{error, _} = Err ->
Err
end;
{error, _} = Err ->
Err
end.
%%%------------------------