From 4ea57c2bf95c9331a26e1a823b47589f6b19dea1 Mon Sep 17 00:00:00 2001 From: Gilbert Wong Date: Sat, 3 Nov 2018 22:56:11 +0800 Subject: [PATCH] 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. --- src/emqx_protocol.erl | 6 ------ src/emqx_ws_connection.erl | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/emqx_protocol.erl b/src/emqx_protocol.erl index 3e5db983f..9ce66bfb8 100644 --- a/src/emqx_protocol.erl +++ b/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. diff --git a/src/emqx_ws_connection.erl b/src/emqx_ws_connection.erl index 407525601..7ff0b55a8 100644 --- a/src/emqx_ws_connection.erl +++ b/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() ->