Merge pull request #536 from emqtt/issue#535

fix issue #535
This commit is contained in:
Feng Lee 2016-04-29 00:23:03 +08:00
commit 770fbcdae6
1 changed files with 6 additions and 1 deletions

View File

@ -79,11 +79,12 @@ init([OriginConn, MqttEnv]) ->
exit({shutdown, Reason})
end,
ConnName = esockd_net:format(PeerName),
Self = self(),
SendFun = fun(Data) ->
try Connection:async_send(Data) of
true -> ok
catch
error:Error -> exit({shutdown, Error})
error:Error -> Self ! {shutdown, Error}
end
end,
PktOpts = proplists:get_value(packet, MqttEnv),
@ -138,6 +139,10 @@ handle_cast(Msg, State) ->
handle_info(timeout, State) ->
shutdown(idle_timeout, State);
%% fix issue #535
handle_info({shutdown, Error}, State) ->
shutdown(Error, State);
%% Asynchronous SUBACK
handle_info({suback, PacketId, GrantedQos}, State) ->
with_proto_state(fun(ProtoState) ->