Просмотр исходного кода

Delete redundant case clauses in sendfun
Prior to this change, there are ok, {binary, _Data}. {datagram, _Peer,
_Dara} case clauses, and the {binary, _Data} and {datagram, _Peer,
_Data} are unnecessary cases

This change delete these two cases and add ok in the end of funtion in
send_fun of emqx_ws_connection.

Gilbert Wong 7 лет назад
Родитель
Сommit
4ea57c2bf9
2 измененных файлов с 2 добавлено и 7 удалено
  1. 0 6
      src/emqx_protocol.erl
  2. 2 1
      src/emqx_ws_connection.erl

+ 0 - 6
src/emqx_protocol.erl

@@ -593,12 +593,6 @@ send(Packet = ?PACKET(Type), PState = #pstate{proto_ver = Ver, sendfun = SendFun
         ok ->
             emqx_metrics:sent(Packet),
             {ok, inc_stats(send, Type, PState)};
-        {binary, _Data} ->
-            emqx_metrics:sent(Packet),
-            {ok, inc_stats(send, Type, PState)};
-        {datagram, _Peer, _Data} ->
-            emqx_metrics:sent(Packet),
-            {ok, inc_stats(send, Type, PState)};
         {error, Reason} ->
             {error, Reason}
     end.

+ 2 - 1
src/emqx_ws_connection.erl

@@ -150,7 +150,8 @@ send_fun(WsPid) ->
         emqx_metrics:inc('bytes/sent', BinSize),
         put(send_oct, get(send_oct) + BinSize),
         put(send_cnt, get(send_cnt) + 1),
-        WsPid ! {binary, iolist_to_binary(Data)}
+        WsPid ! {binary, iolist_to_binary(Data)},
+        ok
     end.
 
 stat_fun() ->