From 8cfd080a97d848b8d808aef435d6f87dbd045f42 Mon Sep 17 00:00:00 2001 From: Gilbert Wong Date: Sun, 7 Apr 2019 22:31:42 +0800 Subject: [PATCH] Fix gen_statem:reply/2 bug in emqx_client module Prior to this change, the arguments passed to gen_statem:reply is bad args, first arg should be a tuple, but it is a pid. So it would trigger crash. This change fix this bug. --- src/emqx_client.erl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/emqx_client.erl b/src/emqx_client.erl index 75b384fcb..371b020f1 100644 --- a/src/emqx_client.erl +++ b/src/emqx_client.erl @@ -1049,7 +1049,7 @@ timeout_calls(Timeout, Calls) -> timeout_calls(Now, Timeout, Calls) -> lists:foldl(fun(C = #call{from = From, ts = Ts}, Acc) -> case (timer:now_diff(Now, Ts) div 1000) >= Timeout of - true -> gen_statem:reply(From, {error, ack_timeout}), + true -> From ! {error, ack_timeout}, Acc; false -> [C | Acc] end @@ -1231,4 +1231,3 @@ bump_last_packet_id(State = #state{last_packet_id = Id}) -> -spec next_packet_id(packet_id()) -> packet_id(). next_packet_id(?MAX_PACKET_ID) -> 1; next_packet_id(Id) -> Id + 1. -