Merge pull request #8650 from qzhuyan/fix/william/keep-alive-check
fix: keep alive check
This commit is contained in:
commit
30f24131e2
|
@ -708,8 +708,6 @@ handle_timeout(
|
||||||
TRef,
|
TRef,
|
||||||
keepalive,
|
keepalive,
|
||||||
State = #state{
|
State = #state{
|
||||||
transport = Transport,
|
|
||||||
socket = Socket,
|
|
||||||
channel = Channel
|
channel = Channel
|
||||||
}
|
}
|
||||||
) ->
|
) ->
|
||||||
|
@ -717,12 +715,9 @@ handle_timeout(
|
||||||
disconnected ->
|
disconnected ->
|
||||||
{ok, State};
|
{ok, State};
|
||||||
_ ->
|
_ ->
|
||||||
case Transport:getstat(Socket, [recv_oct]) of
|
%% recv_pkt: valid MQTT message
|
||||||
{ok, [{recv_oct, RecvOct}]} ->
|
RecvCnt = emqx_pd:get_counter(recv_pkt),
|
||||||
handle_timeout(TRef, {keepalive, RecvOct}, State);
|
handle_timeout(TRef, {keepalive, RecvCnt}, State)
|
||||||
{error, Reason} ->
|
|
||||||
handle_info({sock_error, Reason}, State)
|
|
||||||
end
|
|
||||||
end;
|
end;
|
||||||
handle_timeout(TRef, Msg, State) ->
|
handle_timeout(TRef, Msg, State) ->
|
||||||
with_channel(handle_timeout, [TRef, Msg], State).
|
with_channel(handle_timeout, [TRef, Msg], State).
|
||||||
|
|
|
@ -316,11 +316,6 @@ t_handle_timeout(_) ->
|
||||||
emqx_connection:handle_timeout(TRef, keepalive, State)
|
emqx_connection:handle_timeout(TRef, keepalive, State)
|
||||||
),
|
),
|
||||||
|
|
||||||
ok = meck:expect(emqx_transport, getstat, fun(_Sock, _Options) -> {error, for_testing} end),
|
|
||||||
?assertMatch(
|
|
||||||
{stop, {shutdown, for_testing}, _NState},
|
|
||||||
emqx_connection:handle_timeout(TRef, keepalive, State)
|
|
||||||
),
|
|
||||||
?assertMatch({ok, _NState}, emqx_connection:handle_timeout(TRef, undefined, State)).
|
?assertMatch({ok, _NState}, emqx_connection:handle_timeout(TRef, undefined, State)).
|
||||||
|
|
||||||
t_parse_incoming(_) ->
|
t_parse_incoming(_) ->
|
||||||
|
|
Loading…
Reference in New Issue