]> granicus.if.org Git - ejabberd/commitdiff
Don't ignore send() result
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Tue, 3 Jul 2018 10:44:58 +0000 (13:44 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Tue, 3 Jul 2018 10:44:58 +0000 (13:44 +0300)
src/mod_proxy65_stream.erl

index 4ef6e41fde9b6fffb8b8881ce3a38a8497ebf6c7..418e4588fe6081e61a7fe2ef2b226ee1c20f3e20 100644 (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.
 
 %%%------------------------