This commit is contained in:
Feng 2016-04-29 00:17:07 +08:00
parent 18b8e8195f
commit f5adafe9e2
1 changed files with 6 additions and 1 deletions

View File

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